From 5207fa3eedfaf2d8b6e27ff38c32a716fb25193c Mon Sep 17 00:00:00 2001 From: Christian Kollmann Date: Mon, 22 Feb 2021 13:43:29 +0100 Subject: Refactor: Use EqualsBuilder for equality checks --- .../modules/auth/eidas/v2/dao/SimpleEidasData.java | 48 +++++----------------- 1 file changed, 10 insertions(+), 38 deletions(-) (limited to 'eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus') diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/dao/SimpleEidasData.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/dao/SimpleEidasData.java index 17f2b1ee..84327941 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/dao/SimpleEidasData.java +++ b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/dao/SimpleEidasData.java @@ -26,6 +26,7 @@ package at.asitplus.eidas.specific.modules.auth.eidas.v2.dao; import at.asitplus.eidas.specific.modules.auth.eidas.v2.exception.WorkflowException; import at.gv.e_government.reference.namespace.persondata._20020228.PostalAddressType; import lombok.Data; +import org.apache.commons.lang3.builder.EqualsBuilder; @Data public class SimpleEidasData { @@ -52,44 +53,15 @@ public class SimpleEidasData { * @throws WorkflowException if multiple results have been found */ public boolean equalsRegisterData(MergedRegisterSearchResult result) throws WorkflowException { - return equalsRegisterData(result.getResult()); + return new EqualsBuilder() + .append(result.getResult().getPseudonym(), pseudonym) + .append(result.getResult().getGivenName(), givenName) + .append(result.getResult().getFamilyName(), familyName) + .append(result.getResult().getDateOfBirth(), dateOfBirth) + .append(result.getResult().getPlaceOfBirth(), placeOfBirth) + .append(result.getResult().getBirthName(), birthName) + .append(result.getResult().getTaxNumber(), taxNumber) + .isEquals(); } - private boolean equalsRegisterData(RegisterResult result) { - if (!result.getPseudonym().equals(pseudonym)) { - return false; - } - if (!result.getGivenName().equals(givenName)) { - return false; - } - if (!result.getFamilyName().equals(familyName)) { - return false; - } - if (!result.getDateOfBirth().equals(dateOfBirth)) { - return false; - } - if (!equals(result.getPlaceOfBirth(), placeOfBirth)) { - return false; - } - if (!equals(result.getBirthName(), birthName)) { - return false; - } - if (!equals(result.getTaxNumber(), taxNumber)) { - return false; - } - return true; - } - - private boolean equals(String a, String b) { - if (a == null && b == null) { - return true; - } - if (a == null) { - return false; - } - if (b == null) { - return false; - } - return a.equals(b); - } } -- cgit v1.2.3