11package com .fasterxml .jackson .module .jsonSchema .types ;
22
3+ import java .util .Collections ;
34import java .util .HashSet ;
45import java .util .Set ;
56
1011 * This class encapsulates the functionality of container type {@link JsonSchema}
1112 * Array and Object
1213 * @author jphelan
13- *
1414 */
1515public abstract class ContainerTypeSchema extends SimpleTypeSchema {
1616 /**
@@ -23,12 +23,8 @@ of enum values uses the same algorithm as defined in "uniqueItems"
2323 (Section 5.15).
2424 */
2525 @ JsonProperty (value = "enum" , required = true )
26- private Set <String > enums ;
26+ private Set <String > enums = Collections . emptySet () ;
2727
28- //instance initializer block
29- {
30- enums = new HashSet <String >();
31- }
3228 /**
3329 * This provides an enumeration of all possible values that are valid
3430 for the instance property. This MUST be an array, and each item in
@@ -39,13 +35,7 @@ of enum values uses the same algorithm as defined in "uniqueItems"
3935 (Section 5.15).
4036 */
4137 @ JsonProperty (value = "oneOf" , required = true )
42- private Set <Object > oneOf ;
43- //instance initializer block
44- {
45- oneOf = new HashSet <Object >();
46- }
47-
48-
38+ private Set <Object > oneOf = Collections .emptySet ();
4939
5040 /* (non-Javadoc)
5141 * @see com.fasterxml.jackson.databind.jsonSchema.types.JsonSchema#asContainerSchema()
@@ -58,13 +48,13 @@ of enum values uses the same algorithm as defined in "uniqueItems"
5848 */
5949 @ Override
6050 public boolean equals (Object obj ) {
61- if (obj instanceof ContainerTypeSchema ) {
51+ if (obj == this ) return true ;
52+ if (obj instanceof ContainerTypeSchema ) {
6253 ContainerTypeSchema that = (ContainerTypeSchema )obj ;
6354 return equals (getEnums (), that .getEnums ()) &&
6455 super .equals (obj );
65- } else {
66- return false ;
67- }
56+ }
57+ return false ;
6858 }
6959
7060 public Set <String > getEnums () {
0 commit comments