@@ -51,7 +51,7 @@ public static class Builder extends Schema.Builder<ObjectSchema> {
51
51
52
52
private Schema propertyNameSchema ;
53
53
54
- public Builder additionalProperties (final boolean additionalProperties ) {
54
+ public Builder additionalProperties (boolean additionalProperties ) {
55
55
this .additionalProperties = additionalProperties ;
56
56
return this ;
57
57
}
@@ -66,14 +66,14 @@ public Builder additionalProperties(final boolean additionalProperties) {
66
66
* value will be validated using this {@code schema}
67
67
* @return {@code this}
68
68
*/
69
- public Builder addPropertySchema (final String propName , final Schema schema ) {
69
+ public Builder addPropertySchema (String propName , Schema schema ) {
70
70
requireNonNull (propName , "propName cannot be null" );
71
71
requireNonNull (schema , "schema cannot be null" );
72
72
propertySchemas .put (propName , schema );
73
73
return this ;
74
74
}
75
75
76
- public Builder addRequiredProperty (final String propertyName ) {
76
+ public Builder addRequiredProperty (String propertyName ) {
77
77
requiredProperties .add (propertyName );
78
78
return this ;
79
79
}
@@ -83,22 +83,22 @@ public ObjectSchema build() {
83
83
return new ObjectSchema (this );
84
84
}
85
85
86
- public Builder maxProperties (final Integer maxProperties ) {
86
+ public Builder maxProperties (Integer maxProperties ) {
87
87
this .maxProperties = maxProperties ;
88
88
return this ;
89
89
}
90
90
91
- public Builder minProperties (final Integer minProperties ) {
91
+ public Builder minProperties (Integer minProperties ) {
92
92
this .minProperties = minProperties ;
93
93
return this ;
94
94
}
95
95
96
- public Builder patternProperty (final Pattern pattern , final Schema schema ) {
96
+ public Builder patternProperty (Pattern pattern , Schema schema ) {
97
97
this .patternProperties .put (pattern , schema );
98
98
return this ;
99
99
}
100
100
101
- public Builder patternProperty (final String pattern , final Schema schema ) {
101
+ public Builder patternProperty (String pattern , Schema schema ) {
102
102
return patternProperty (Pattern .compile (pattern ), schema );
103
103
}
104
104
@@ -113,7 +113,7 @@ public Builder patternProperty(final String pattern, final Schema schema) {
113
113
* named {@code ifPresent} exists
114
114
* @return {@code this}
115
115
*/
116
- public Builder propertyDependency (final String ifPresent , final String mustBePresent ) {
116
+ public Builder propertyDependency (String ifPresent , String mustBePresent ) {
117
117
Set <String > dependencies = propertyDependencies .get (ifPresent );
118
118
if (dependencies == null ) {
119
119
dependencies = new HashSet <String >(1 );
@@ -123,17 +123,17 @@ public Builder propertyDependency(final String ifPresent, final String mustBePre
123
123
return this ;
124
124
}
125
125
126
- public Builder requiresObject (final boolean requiresObject ) {
126
+ public Builder requiresObject (boolean requiresObject ) {
127
127
this .requiresObject = requiresObject ;
128
128
return this ;
129
129
}
130
130
131
- public Builder schemaDependency (final String ifPresent , final Schema expectedSchema ) {
131
+ public Builder schemaDependency (String ifPresent , Schema expectedSchema ) {
132
132
schemaDependencies .put (ifPresent , expectedSchema );
133
133
return this ;
134
134
}
135
135
136
- public Builder schemaOfAdditionalProperties (final Schema schemaOfAdditionalProperties ) {
136
+ public Builder schemaOfAdditionalProperties (Schema schemaOfAdditionalProperties ) {
137
137
this .schemaOfAdditionalProperties = schemaOfAdditionalProperties ;
138
138
return this ;
139
139
}
@@ -149,7 +149,7 @@ public static Builder builder() {
149
149
return new Builder ();
150
150
}
151
151
152
- private static <K , V > Map <K , V > copyMap (final Map <K , V > original ) {
152
+ private static <K , V > Map <K , V > copyMap (Map <K , V > original ) {
153
153
return Collections .unmodifiableMap (new HashMap <>(original ));
154
154
}
155
155
@@ -181,7 +181,7 @@ private static <K, V> Map<K, V> copyMap(final Map<K, V> original) {
181
181
* @param builder
182
182
* the builder object containing validation criteria
183
183
*/
184
- public ObjectSchema (final Builder builder ) {
184
+ public ObjectSchema (Builder builder ) {
185
185
super (builder );
186
186
this .propertySchemas = builder .propertySchemas == null ? null
187
187
: Collections .unmodifiableMap (builder .propertySchemas );
@@ -202,7 +202,7 @@ public ObjectSchema(final Builder builder) {
202
202
this .propertyNameSchema = builder .propertyNameSchema ;
203
203
}
204
204
205
- private List <String > getAdditionalProperties (final JSONObject subject ) {
205
+ private List <String > getAdditionalProperties (JSONObject subject ) {
206
206
String [] names = JSONObject .getNames (subject );
207
207
if (names == null ) {
208
208
return new ArrayList <>();
@@ -253,7 +253,7 @@ public Schema getPropertyNameSchema() {
253
253
return propertyNameSchema ;
254
254
}
255
255
256
- private Optional <ValidationException > ifFails (final Schema schema , final Object input ) {
256
+ private Optional <ValidationException > ifFails (Schema schema , Object input ) {
257
257
try {
258
258
schema .validate (input );
259
259
return Optional .empty ();
@@ -266,7 +266,7 @@ private Optional<ValidationException> ifFails(final Schema schema, final Object
266
266
throw new UnsupportedOperationException ("not yet implemented" );
267
267
}
268
268
269
- private boolean matchesAnyPattern (final String key ) {
269
+ private boolean matchesAnyPattern (String key ) {
270
270
for (Pattern pattern : patternProperties .keySet ()) {
271
271
if (pattern .matcher (key ).find ()) {
272
272
return true ;
@@ -283,7 +283,7 @@ public boolean requiresObject() {
283
283
return requiresObject ;
284
284
}
285
285
286
- private void testAdditionalProperties (final JSONObject subject , List <ValidationException > validationExceptions ) {
286
+ private void testAdditionalProperties (JSONObject subject , List <ValidationException > validationExceptions ) {
287
287
if (!additionalProperties ) {
288
288
List <String > additionalProperties = getAdditionalProperties (subject );
289
289
if (null == additionalProperties || additionalProperties .isEmpty ()) {
@@ -305,7 +305,7 @@ private void testAdditionalProperties(final JSONObject subject, List<ValidationE
305
305
}
306
306
}
307
307
308
- private void testPatternProperties (final JSONObject subject , List <ValidationException > validationExceptions ) {
308
+ private void testPatternProperties (JSONObject subject , List <ValidationException > validationExceptions ) {
309
309
String [] propNames = JSONObject .getNames (subject );
310
310
if (propNames == null || propNames .length == 0 ) {
311
311
return ;
@@ -322,7 +322,7 @@ private void testPatternProperties(final JSONObject subject, List<ValidationExce
322
322
}
323
323
}
324
324
325
- private void testProperties (final JSONObject subject , List <ValidationException > validationExceptions ) {
325
+ private void testProperties (JSONObject subject , List <ValidationException > validationExceptions ) {
326
326
if (propertySchemas != null ) {
327
327
for (Entry <String , Schema > entry : propertySchemas .entrySet ()) {
328
328
String key = entry .getKey ();
@@ -338,7 +338,7 @@ private void testProperties(final JSONObject subject, List<ValidationException>
338
338
}
339
339
}
340
340
341
- private void testPropertyDependencies (final JSONObject subject , List <ValidationException > validationExceptions ) {
341
+ private void testPropertyDependencies (JSONObject subject , List <ValidationException > validationExceptions ) {
342
342
for (String property : propertyDependencies .keySet ()) {
343
343
if (subject .has (property )) {
344
344
for (String mustBePresent : propertyDependencies .get (property )) {
@@ -351,7 +351,7 @@ private void testPropertyDependencies(final JSONObject subject, List<ValidationE
351
351
}
352
352
}
353
353
354
- private void testRequiredProperties (final JSONObject subject , List <ValidationException > validationExceptions ) {
354
+ private void testRequiredProperties (JSONObject subject , List <ValidationException > validationExceptions ) {
355
355
for (String required : requiredProperties ) {
356
356
if (!subject .has (required )) {
357
357
validationExceptions .add (
@@ -360,7 +360,7 @@ private void testRequiredProperties(final JSONObject subject, List<ValidationExc
360
360
}
361
361
}
362
362
363
- private void testSchemaDependencies (final JSONObject subject , List <ValidationException > validationExceptions ) {
363
+ private void testSchemaDependencies (JSONObject subject , List <ValidationException > validationExceptions ) {
364
364
for (Map .Entry <String , Schema > schemaDep : schemaDependencies .entrySet ()) {
365
365
String propName = schemaDep .getKey ();
366
366
if (subject .has (propName )) {
@@ -369,7 +369,7 @@ private void testSchemaDependencies(final JSONObject subject, List<ValidationExc
369
369
}
370
370
}
371
371
372
- private void testSize (final JSONObject subject , List <ValidationException > validationExceptions ) {
372
+ private void testSize (JSONObject subject , List <ValidationException > validationExceptions ) {
373
373
int actualSize = subject .length ();
374
374
if (minProperties != null && actualSize < minProperties .intValue ()) {
375
375
validationExceptions .addAll (
@@ -385,7 +385,7 @@ private void testSize(final JSONObject subject, List<ValidationException> valida
385
385
}
386
386
387
387
@ Override
388
- public void validate (final Object subject ) {
388
+ public void validate (Object subject ) {
389
389
if (!(subject instanceof JSONObject )) {
390
390
if (requiresObject ) {
391
391
throw failure (JSONObject .class , subject );
@@ -438,7 +438,7 @@ public boolean definesProperty(String field) {
438
438
|| definesSchemaDependencyProperty (field ));
439
439
}
440
440
441
- private boolean definesSchemaProperty (String current , final String remaining ) {
441
+ private boolean definesSchemaProperty (String current , String remaining ) {
442
442
current = unescape (current );
443
443
boolean hasSuffix = !(remaining == null );
444
444
if (propertySchemas .containsKey (current )) {
@@ -451,7 +451,7 @@ private boolean definesSchemaProperty(String current, final String remaining) {
451
451
return false ;
452
452
}
453
453
454
- private boolean definesPatternProperty (final String current , final String remaining ) {
454
+ private boolean definesPatternProperty (String current , String remaining ) {
455
455
for (Pattern pattern : patternProperties .keySet ()) {
456
456
if (pattern .matcher (current ).matches ()) {
457
457
if (remaining == null || patternProperties .get (pattern ).definesProperty (remaining )) {
@@ -462,7 +462,7 @@ private boolean definesPatternProperty(final String current, final String remain
462
462
return false ;
463
463
}
464
464
465
- private boolean definesSchemaDependencyProperty (final String field ) {
465
+ private boolean definesSchemaDependencyProperty (String field ) {
466
466
if (schemaDependencies .containsKey (field )) {
467
467
return true ;
468
468
}
@@ -474,7 +474,7 @@ private boolean definesSchemaDependencyProperty(final String field) {
474
474
return false ;
475
475
}
476
476
477
- private String unescape (final String value ) {
477
+ private String unescape (String value ) {
478
478
return value .replace ("~1" , "/" ).replace ("~0" , "~" );
479
479
}
480
480
0 commit comments