Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 21 additions & 4 deletions src/main/java/com/fasterxml/jackson/annotation/JsonTypeInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -460,8 +460,14 @@ public String toString() {

@Override
public int hashCode() {
return Objects.hash(_idType, _inclusionType, _propertyName, _defaultImpl, _requireTypeIdForSubtypes)
+ (_idVisible ? 11 : -17);
int hashCode = 1;
hashCode = 31 * hashCode + (_idType != null ? _idType.hashCode() : 0);
hashCode = 31 * hashCode + (_inclusionType != null ? _inclusionType.hashCode() : 0);
hashCode = 31 * hashCode + (_propertyName != null ? _propertyName.hashCode() : 0);
hashCode = 31 * hashCode + (_defaultImpl != null ? _defaultImpl.hashCode() : 0);
hashCode = 31 * hashCode + (_requireTypeIdForSubtypes ? 11 : -17);
hashCode = 31 * hashCode + (_idVisible ? 11 : -17);
return hashCode;
}

@Override
Expand All @@ -478,9 +484,20 @@ private static boolean _equals(Value a, Value b)
&& (a._inclusionType == b._inclusionType)
&& (a._defaultImpl == b._defaultImpl)
&& (a._idVisible == b._idVisible)
&& Objects.equals(a._propertyName, b._propertyName)
&& Objects.equals(a._requireTypeIdForSubtypes, b._requireTypeIdForSubtypes)
&& _equal(a._propertyName, b._propertyName)
&& _equal(a._requireTypeIdForSubtypes, b._requireTypeIdForSubtypes)
;
}

private static <T> boolean _equal(T value1, T value2)
{
if (value1 == null) {
return (value2 == null);
}
if (value2 == null) {
return false;
}
return value1.equals(value2);
}
}
}