diff --git a/src/main/java/com/fasterxml/jackson/annotation/JsonTypeInfo.java b/src/main/java/com/fasterxml/jackson/annotation/JsonTypeInfo.java index e1a11f37..159028ab 100644 --- a/src/main/java/com/fasterxml/jackson/annotation/JsonTypeInfo.java +++ b/src/main/java/com/fasterxml/jackson/annotation/JsonTypeInfo.java @@ -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 @@ -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 boolean _equal(T value1, T value2) + { + if (value1 == null) { + return (value2 == null); + } + if (value2 == null) { + return false; + } + return value1.equals(value2); + } } }