Skip to content

Commit e8a655a

Browse files
SdkComponentDescriptor: Fix equals() and hasCode() methods
We need to also consider the "implType" field when comparing two instances or calculating the hash code. This makes the check in SdkComponentFactory that there are two components with the same version and type actually work and throw the intended exception. As we have this situation in unit test, any test that uses SdkComponentFactory currently fails because of this exception. This will addressed in the next commit.
1 parent 75db941 commit e8a655a

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

src/main/java/eu/europa/ted/eforms/sdk/component/SdkComponentDescriptor.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ private boolean constructorHasExpectedParameters(Constructor<?> constructor,
9494

9595
@Override
9696
public int hashCode() {
97-
return Objects.hash(componentType, sdkVersion);
97+
return Objects.hash(sdkVersion, componentType, implType);
9898
}
9999

100100
@Override
@@ -106,7 +106,9 @@ public boolean equals(Object obj) {
106106
if (getClass() != obj.getClass())
107107
return false;
108108
SdkComponentDescriptor<?> other = (SdkComponentDescriptor<?>) obj;
109-
return componentType == other.componentType && Objects.equals(sdkVersion, other.sdkVersion);
109+
return componentType == other.componentType
110+
&& Objects.equals(sdkVersion, other.sdkVersion)
111+
&& Objects.equals(implType, other.implType);
110112
}
111113

112114
public Class<T> getImplType() {

0 commit comments

Comments
 (0)