Skip to content

Commit 1f99f6d

Browse files
committed
checkstyle fixes
1 parent 91d4aff commit 1f99f6d

14 files changed

+210
-35
lines changed

core/src/main/java/org/everit/jsonvalidator/ArraySchema.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@
2323
import org.json.JSONArray;
2424

2525
/**
26-
* Array schema.
26+
* Array schema validator.
27+
*
28+
* {@link http://json-schema.org/latest/json-schema-validation.html#anchor36 See the according
29+
* specification}.
2730
*/
2831
public class ArraySchema extends Schema {
2932

@@ -79,6 +82,7 @@ public Builder allItemSchema(final Schema allItemSchema) {
7982
return this;
8083
}
8184

85+
@Override
8286
public ArraySchema build() {
8387
return new ArraySchema(this);
8488
}

core/src/main/java/org/everit/jsonvalidator/BooleanSchema.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,15 @@
1616
package org.everit.jsonvalidator;
1717

1818
/**
19-
* Boolean validator.
19+
* Boolean schema validator.
2020
*/
2121
public class BooleanSchema extends Schema {
2222

2323
public static final BooleanSchema INSTANCE = new BooleanSchema(builder());
2424

25+
/**
26+
* Builder class for {@link BooleanSchema}.
27+
*/
2528
public static class Builder extends Schema.Builder {
2629

2730
@Override

core/src/main/java/org/everit/jsonvalidator/CombinedSchema.java

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,22 @@
2121

2222
/**
2323
* Validator for {@code allOf}, {@code oneOf}, {@code anyOf} schemas.
24+
*
25+
* <p>
26+
* See the following paragraphs of the specification for more details:
27+
* <ul>
28+
* <li>{@link http://json-schema.org/latest/json-schema-validation.html#anchor82}</li>
29+
* <li>{@link http://json-schema.org/latest/json-schema-validation.html#anchor85}</li>
30+
* <li>{@link http://json-schema.org/latest/json-schema-validation.html#anchor88}</li>
31+
* </ul>
32+
* </p>
2433
*/
2534
public class CombinedSchema extends Schema {
2635

27-
public static class Builder extends Schema.Builder {
36+
/**
37+
* Builder class for {@link CombinedSchema}.
38+
*/
39+
public static class Builder extends Schema.Builder<CombinedSchema> {
2840

2941
private ValidationCriterion criterion;
3042

@@ -45,6 +57,7 @@ public Builder subschemas(final Collection<Schema> subschemas) {
4557
return this;
4658
}
4759

60+
@Override
4861
public CombinedSchema build() {
4962
return new CombinedSchema(this);
5063
}
@@ -120,6 +133,9 @@ public static Builder oneOf(final Collection<Schema> schemas) {
120133

121134
private final ValidationCriterion criterion;
122135

136+
/**
137+
* Constructor.
138+
*/
123139
public CombinedSchema(final Builder builder) {
124140
super(builder);
125141
this.criterion = Objects.requireNonNull(builder.criterion, "criterion cannot be null");

core/src/main/java/org/everit/jsonvalidator/EmptySchema.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public EmptySchema(final Builder builder) {
4444

4545
@Override
4646
public void validate(final Object subject) {
47-
// always true
47+
// always passing
4848
}
4949

5050
}

core/src/main/java/org/everit/jsonvalidator/EnumSchema.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,17 @@
2020
import java.util.Set;
2121

2222
/**
23-
* Enum schema.
23+
* {@link Enum} schema validator.
24+
*
25+
* {@link http://json-schema.org/latest/json-schema-validation.html#anchor76 See the according
26+
* specification}.
2427
*/
2528
public class EnumSchema extends Schema {
2629

27-
public static class Builder extends Schema.Builder {
30+
/**
31+
* Builder class for {@link EnumSchema}.
32+
*/
33+
public static class Builder extends Schema.Builder<EnumSchema> {
2834

2935
private Set<Object> possibleValues = new HashSet<>();
3036

@@ -58,7 +64,7 @@ public void validate(final Object subject) {
5864
.findAny()
5965
.orElseThrow(
6066
() -> new ValidationException(String.format("%s is not a valid enum value",
61-
subject.toString())));
67+
subject)));
6268
}
6369

6470
public Set<Object> getPossibleValues() {

core/src/main/java/org/everit/jsonvalidator/NotSchema.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,16 @@
1818
import java.util.Objects;
1919

2020
/**
21-
* Not schema validator.
21+
* {@code Not} schema validator.
22+
*
23+
* {@link http://json-schema.org/latest/json-schema-validation.html#anchor91 See the according
24+
* specification}.
2225
*/
2326
public class NotSchema extends Schema {
2427

28+
/**
29+
* Builder class for {@link NotSchema}.
30+
*/
2531
public static class Builder extends Schema.Builder {
2632

2733
private Schema mustNotMatch;
@@ -31,6 +37,7 @@ public Builder mustNotMatch(final Schema mustNotMatch) {
3137
return this;
3238
}
3339

40+
@Override
3441
public NotSchema build() {
3542
return new NotSchema(this);
3643
}

core/src/main/java/org/everit/jsonvalidator/NullSchema.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,16 @@
1818
import org.json.JSONObject;
1919

2020
/**
21-
* Null schema validator.
21+
* {@code Null} schema validator.
2222
*/
2323
public class NullSchema extends Schema {
2424

2525
public static final NullSchema INSTANCE = new NullSchema(builder());
2626

27-
public static class Builder extends Schema.Builder {
27+
/**
28+
* Builder class for {@link NullSchema}.
29+
*/
30+
public static class Builder extends Schema.Builder<NullSchema> {
2831

2932
@Override
3033
public NullSchema build() {

core/src/main/java/org/everit/jsonvalidator/NumberSchema.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@
1818
import java.math.BigDecimal;
1919

2020
/**
21-
* Integer schema.
21+
* Number schema validator.
2222
*/
2323
public class NumberSchema extends Schema {
2424

2525
/**
2626
* Builder class for {@link NumberSchema}.
2727
*/
28-
public static class Builder extends Schema.Builder {
28+
public static class Builder extends Schema.Builder<NumberSchema> {
2929

3030
private Number minimum;
3131

@@ -41,6 +41,7 @@ public static class Builder extends Schema.Builder {
4141

4242
private boolean requiresInteger = false;
4343

44+
@Override
4445
public NumberSchema build() {
4546
return new NumberSchema(this);
4647
}

core/src/main/java/org/everit/jsonvalidator/ObjectSchema.java

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public class ObjectSchema extends Schema {
3838
/**
3939
* Builder class for {@link ObjectSchema}.
4040
*/
41-
public static class Builder extends Schema.Builder {
41+
public static class Builder extends Schema.Builder<ObjectSchema> {
4242

4343
private final Map<Pattern, Schema> patternProperties = new HashMap<>();
4444

@@ -94,6 +94,7 @@ public Builder addRequiredProperty(final String propertyName) {
9494
return this;
9595
}
9696

97+
@Override
9798
public ObjectSchema build() {
9899
return new ObjectSchema(this);
99100
}
@@ -163,7 +164,7 @@ public static Builder builder() {
163164
public ObjectSchema(final Builder builder) {
164165
super(builder);
165166
this.propertySchemas = builder.propertySchemas == null ? null :
166-
Collections.unmodifiableMap(builder.propertySchemas);
167+
Collections.unmodifiableMap(builder.propertySchemas);
167168
this.additionalProperties = builder.additionalProperties;
168169
this.schemaOfAdditionalProperties = builder.schemaOfAdditionalProperties;
169170
if (!additionalProperties && schemaOfAdditionalProperties != null) {
@@ -226,12 +227,12 @@ private boolean matchesAnyPattern(final String key) {
226227
private void testAdditionalProperties(final JSONObject subject) {
227228
if (!additionalProperties) {
228229
getAdditionalProperties(subject)
229-
.findFirst()
230-
.ifPresent(unneeded -> failure("extraneous key [%s] is not permitted", unneeded));
230+
.findFirst()
231+
.ifPresent(unneeded -> failure("extraneous key [%s] is not permitted", unneeded));
231232
} else if (schemaOfAdditionalProperties != null) {
232233
getAdditionalProperties(subject)
233-
.map(subject::get)
234-
.forEach(schemaOfAdditionalProperties::validate);
234+
.map(subject::get)
235+
.forEach(schemaOfAdditionalProperties::validate);
235236
}
236237
}
237238

@@ -255,25 +256,25 @@ private void testProperties(final JSONObject subject) {
255256

256257
private void testPropertyDependencies(final JSONObject subject) {
257258
propertyDependencies.keySet().stream()
258-
.filter(subject::has)
259-
.flatMap(ifPresent -> propertyDependencies.get(ifPresent).stream())
260-
.filter(mustBePresent -> !subject.has(mustBePresent))
261-
.findFirst()
262-
.ifPresent(missing -> failure("property [%s] is required", missing));
259+
.filter(subject::has)
260+
.flatMap(ifPresent -> propertyDependencies.get(ifPresent).stream())
261+
.filter(mustBePresent -> !subject.has(mustBePresent))
262+
.findFirst()
263+
.ifPresent(missing -> failure("property [%s] is required", missing));
263264
}
264265

265266
private void testRequiredProperties(final JSONObject subject) {
266267
requiredProperties.stream()
267-
.filter(key -> !subject.has(key))
268-
.findFirst()
269-
.ifPresent(missing -> failure("required key [%s] not found", missing));
268+
.filter(key -> !subject.has(key))
269+
.findFirst()
270+
.ifPresent(missing -> failure("required key [%s] not found", missing));
270271
}
271272

272273
private void testSchemaDependencies(final JSONObject subject) {
273274
schemaDependencies.keySet().stream()
274-
.filter(subject::has)
275-
.map(schemaDependencies::get)
276-
.forEach(schema -> schema.validate(subject));
275+
.filter(subject::has)
276+
.map(schemaDependencies::get)
277+
.forEach(schema -> schema.validate(subject));
277278
}
278279

279280
private void testSize(final JSONObject subject) {

core/src/main/java/org/everit/jsonvalidator/ReferenceSchema.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,23 @@
1515
*/
1616
package org.everit.jsonvalidator;
1717

18+
/**
19+
* This class is used by {@link org.everit.jsonvalidator.loader.SchemaLoader} to resolve references
20+
* to the root schema, during the construction of the schema.
21+
*/
1822
public class ReferenceSchema extends Schema {
1923

20-
public static class Builder extends Schema.Builder {
24+
/**
25+
* Builder class for {@link ReferenceSchema}.
26+
*/
27+
public static class Builder extends Schema.Builder<ReferenceSchema> {
2128

2229
private ReferenceSchema retval;
2330

31+
/**
32+
* This method caches its result, so multiple invocations will return referentially the same
33+
* {@link ReferenceSchema} instance.
34+
*/
2435
@Override
2536
public ReferenceSchema build() {
2637
if (retval == null) {
@@ -53,6 +64,10 @@ public Schema getReferredSchema() {
5364
return referredSchema;
5465
}
5566

67+
/**
68+
* Called by {@link org.everit.jsonvalidator.loader.SchemaLoader#load()} to set the referred root
69+
* schema after completing the loading process of the entire schema document.
70+
*/
5671
public void setReferredSchema(final Schema referredSchema) {
5772
if (this.referredSchema != null) {
5873
throw new IllegalStateException("referredSchema can be injected only once");

0 commit comments

Comments
 (0)