Remove redundant constructors (#14248)

This commit is contained in:
Grzegorz Piwowarek 2023-06-25 14:38:28 +02:00 committed by GitHub
parent 7464d2b90e
commit 69fe2bb1ae
3 changed files with 4 additions and 16 deletions

View File

@ -9,13 +9,6 @@ public class Citizen {
private String email;
private Integer birthYear;
public Citizen() {
}
public Citizen(String name) {
this.name = name;
}
public String getName() {
return name;
}

View File

@ -10,13 +10,6 @@ public class EncryptedCitizen {
private Binary email;
private Binary birthYear;
public EncryptedCitizen() {
}
public EncryptedCitizen(String name) {
this.name = name;
}
public String getName() {
return name;
}

View File

@ -42,7 +42,8 @@ public class CitizenService {
if (encryptionConfig.isAutoEncryption()) {
return mongo.save(citizen);
} else {
EncryptedCitizen encryptedCitizen = new EncryptedCitizen(citizen.getName());
EncryptedCitizen encryptedCitizen = new EncryptedCitizen();
encryptedCitizen.setName(citizen.getName());
if (citizen.getEmail() != null) {
encryptedCitizen.setEmail(encrypt(citizen.getEmail(), DETERMINISTIC_ALGORITHM));
} else {
@ -123,7 +124,8 @@ public class CitizenService {
private Citizen decrypt(EncryptedCitizen encrypted) {
Objects.requireNonNull(encrypted);
Citizen citizen = new Citizen(encrypted.getName());
Citizen citizen = new Citizen();
citizen.setName(encrypted.getName());
BsonValue decryptedBirthYear = encrypted.getBirthYear() != null ? decryptProperty(encrypted.getBirthYear()) : null;
if (decryptedBirthYear != null) {