0

I have this class

@Data
@NoArgsConstructor
public class DittaIndividualeDTO implements Dati {

    private String denominazione;
    private String nome;
    private String cognome;
    private String sesso;
    @JsonFormat(pattern = "yyyy-MM-dd")
    private Date dataNascita;
    private String luogoNascita;
    private String provinciaNascita;
    private String nazioneNascita;

    private String codiceFiscale;
    private String numeroRea;
    private String provinciaCCIAA;
    private String partitaIVA;
    
    private boolean forzaNome;
    private boolean forzaComune;
    private boolean forzaCodiceFiscale;
    
}

I need to join variables partitaIVA and codiceFiscale: every usage of these variables must be replaced with new variable partitaIvaOCodiceFiscale. Is it possible to do this refactor in IntelliJ? The only thing I have found is combining classes, but is not my case.

2
  • why don't you answer with this? Commented Jun 26, 2024 at 8:55
  • thanks, I just moved my comment to an answer. I initially thought it was too short for it to be an answer. Commented Jun 26, 2024 at 8:57

2 Answers 2

1

The solution I have found is to refactor --> rename all two variables to the same name, then delete one of them.

Sign up to request clarification or add additional context in comments.

Comments

1

In places where you feel that you need to keep different data in the same variable (such as partitaIvaOCodiceFiscale - "VAT number or tax ID code" in English), the proper fix is often to create a class hierarchy. Create a common interface, implemented by two data classes: one that applies to people who have a partitaIVA and one that applies to people who have a codiceFiscale. In the database, you might use two separate tables. However, for simple cases, this might be over-engineering.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.