Search code examples
javavariablesintellij-idearefactoring

IntelliJ refactoring: join two variables into once


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.


Solution

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