1
1
package com .fasterxml .jackson .module .jsonSchema .types ;
2
2
3
+ import java .util .Collections ;
3
4
import java .util .HashSet ;
4
5
import java .util .Set ;
5
6
10
11
* This class encapsulates the functionality of container type {@link JsonSchema}
11
12
* Array and Object
12
13
* @author jphelan
13
- *
14
14
*/
15
15
public abstract class ContainerTypeSchema extends SimpleTypeSchema {
16
16
/**
@@ -23,12 +23,8 @@ of enum values uses the same algorithm as defined in "uniqueItems"
23
23
(Section 5.15).
24
24
*/
25
25
@ JsonProperty (value = "enum" , required = true )
26
- private Set <String > enums ;
26
+ private Set <String > enums = Collections . emptySet () ;
27
27
28
- //instance initializer block
29
- {
30
- enums = new HashSet <String >();
31
- }
32
28
/**
33
29
* This provides an enumeration of all possible values that are valid
34
30
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"
39
35
(Section 5.15).
40
36
*/
41
37
@ 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 ();
49
39
50
40
/* (non-Javadoc)
51
41
* @see com.fasterxml.jackson.databind.jsonSchema.types.JsonSchema#asContainerSchema()
@@ -58,13 +48,13 @@ of enum values uses the same algorithm as defined in "uniqueItems"
58
48
*/
59
49
@ Override
60
50
public boolean equals (Object obj ) {
61
- if (obj instanceof ContainerTypeSchema ) {
51
+ if (obj == this ) return true ;
52
+ if (obj instanceof ContainerTypeSchema ) {
62
53
ContainerTypeSchema that = (ContainerTypeSchema )obj ;
63
54
return equals (getEnums (), that .getEnums ()) &&
64
55
super .equals (obj );
65
- } else {
66
- return false ;
67
- }
56
+ }
57
+ return false ;
68
58
}
69
59
70
60
public Set <String > getEnums () {
0 commit comments