Skip to content

Commit 9be2b0a

Browse files
Merge pull request #2 from erosb/master
javadoc improvements
2 parents c32fc13 + 7432cf9 commit 9be2b0a

File tree

11 files changed

+78
-12
lines changed

11 files changed

+78
-12
lines changed

core/src/main/java/org/everit/json/schema/ArraySchema.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,14 @@ public static class Builder extends Schema.Builder<ArraySchema> {
4949
private Schema schemaOfAdditionalItems;
5050

5151
/**
52-
* Adds an item schema for tuple validation.
52+
* Adds an item schema for tuple validation. The array items of the subject under validation
53+
* will be matched to expected schemas by their index. In other words the {n}th
54+
* {@code addItemSchema()} invocation defines the expected schema of the {n}th item of the array
55+
* being validated.
56+
*
57+
* @param itemSchema
58+
* the schema of the next item.
59+
* @return this
5360
*/
5461
public Builder addItemSchema(final Schema itemSchema) {
5562
if (itemSchemas == null) {
@@ -122,6 +129,9 @@ public static Builder builder() {
122129

123130
/**
124131
* Constructor.
132+
*
133+
* @param builder
134+
* contains validation criteria.
125135
*/
126136
public ArraySchema(final Builder builder) {
127137
super(builder);

core/src/main/java/org/everit/json/schema/CombinedSchema.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,12 @@ public interface ValidationCriterion {
7272
/**
7373
* Throws a {@link ValidationException} if the implemented criterion is not fulfilled by the
7474
* {@code subschemaCount} and the {@code matchingSubschemaCount}.
75+
*
76+
* @param subschemaCount
77+
* the total number of checked subschemas
78+
* @param matchingSubschemaCount
79+
* the number of subschemas which successfully validated the subject (did not throw
80+
* {@link ValidationException})
7581
*/
7682
void validate(int subschemaCount, int matchingSubschemaCount);
7783

@@ -126,6 +132,9 @@ public static Builder oneOf(final Collection<Schema> schemas) {
126132

127133
/**
128134
* Constructor.
135+
*
136+
* @param builder
137+
* the builder containing the validation criterion and the subschemas to be checked
129138
*/
130139
public CombinedSchema(final Builder builder) {
131140
super(builder);

core/src/main/java/org/everit/json/schema/NumberSchema.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,9 @@ public NumberSchema() {
107107

108108
/**
109109
* Constructor.
110+
*
111+
* @param builder
112+
* the builder object containing validation criteria
110113
*/
111114
public NumberSchema(final Builder builder) {
112115
super(builder);

core/src/main/java/org/everit/json/schema/ObjectComparator.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ public final class ObjectComparator {
2828

2929
/**
3030
* Deep-equals implementation on primitive wrappers, {@link JSONObject} and {@link JSONArray}.
31+
*
32+
* @param obj1
33+
* the first object to be inspected
34+
* @param obj2
35+
* the second object to be inspected
36+
* @return {@code true} if the two objects are equal, {@code false} otherwise
3137
*/
3238
public static boolean deepEquals(final Object obj1, final Object obj2) {
3339
if (obj1 instanceof JSONArray) {

core/src/main/java/org/everit/json/schema/ObjectSchema.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,13 @@ public Builder patternProperty(final String pattern, final Schema schema) {
8181

8282
/**
8383
* Adds a property schema.
84+
*
85+
* @param propName
86+
* the name of the property which' expected schema must be {@code schema}
87+
* @param schema
88+
* if the subject under validation has a property named {@code propertyName} then its
89+
* value will be validated using this {@code schema}
90+
* @return {@code this}
8491
*/
8592
public Builder addPropertySchema(final String propName, final Schema schema) {
8693
Objects.requireNonNull(propName, "propName cannot be null");
@@ -111,6 +118,14 @@ public Builder minProperties(final Integer minProperties) {
111118

112119
/**
113120
* Adds a property dependency.
121+
*
122+
* @param ifPresent
123+
* the name of the property which if is present then a property with name
124+
* {@code mustBePresent} is mandatory
125+
* @param mustBePresent
126+
* a property with this name must exist in the subject under validation if a property
127+
* named {@code ifPresent} exists
128+
* @return {@code this}
114129
*/
115130
public Builder propertyDependency(final String ifPresent, final String mustBePresent) {
116131
Set<String> dependencies = propertyDependencies.get(ifPresent);
@@ -160,6 +175,9 @@ public static Builder builder() {
160175

161176
/**
162177
* Constructor.
178+
*
179+
* @param builder
180+
* the builder object containing validation criteria
163181
*/
164182
public ObjectSchema(final Builder builder) {
165183
super(builder);

core/src/main/java/org/everit/json/schema/ReferenceSchema.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
package org.everit.json.schema;
1717

1818
/**
19-
* This class is used by {@link org.everit.json.schema.loader.SchemaLoader} to resolve JSON
20-
* pointers during the construction of the schema. This class has been made mutable to permit the
21-
* loading of recursive schemas.
19+
* This class is used by {@link org.everit.json.schema.loader.SchemaLoader} to resolve JSON pointers
20+
* during the construction of the schema. This class has been made mutable to permit the loading of
21+
* recursive schemas.
2222
*/
2323
public class ReferenceSchema extends Schema {
2424

@@ -68,6 +68,9 @@ public Schema getReferredSchema() {
6868
/**
6969
* Called by {@link org.everit.json.schema.loader.SchemaLoader#load()} to set the referred root
7070
* schema after completing the loading process of the entire schema document.
71+
*
72+
* @param referredSchema
73+
* the referred schema
7174
*/
7275
public void setReferredSchema(final Schema referredSchema) {
7376
if (this.referredSchema != null) {

core/src/main/java/org/everit/json/schema/Schema.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ public Builder<S> id(final String id) {
6565

6666
/**
6767
* Constructor.
68+
*
69+
* @param builder
70+
* the builder containing the optional title, description and id attributes of the schema
6871
*/
6972
protected Schema(final Builder<?> builder) {
7073
this.title = builder.title;

core/src/main/java/org/everit/json/schema/StringSchema.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public class StringSchema extends Schema {
2525
/**
2626
* Builder class for {@link StringSchema}.
2727
*/
28-
public static class Builder extends Schema.Builder {
28+
public static class Builder extends Schema.Builder<StringSchema> {
2929

3030
private Integer minLength;
3131

@@ -80,6 +80,9 @@ public StringSchema() {
8080

8181
/**
8282
* Constructor.
83+
*
84+
* @param builder
85+
* the builder object containing validation criteria
8386
*/
8487
public StringSchema(final Builder builder) {
8588
super(builder);

core/src/main/java/org/everit/json/schema/loader/SchemaClient.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,13 @@
1919
import java.util.function.Function;
2020

2121
/**
22-
* This interface is used by {@link SchemaLoader} and {@link JSONPointer} to fetch the contents
23-
* denoted by remote JSON pointer.
22+
* This interface is used by {@link SchemaLoader} to fetch the contents denoted by remote JSON
23+
* pointer.
2424
*
2525
* <p>
2626
* Implementations are expected to support the HTTP/1.1 protocol, the support of other protocols is
2727
* optional.
2828
* </p>
29-
*
30-
* @see DefaultSchemaClient
3129
*/
3230
@FunctionalInterface
3331
public interface SchemaClient extends Function<String, InputStream> {

core/src/main/java/org/everit/json/schema/loader/SchemaLoader.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ public static Schema load(final JSONObject schemaJson) {
101101
* the JSON representation of the schema.
102102
* @param httpClient
103103
* the HTTP client to be used for resolving remote JSON references.
104+
* @return the created schema
104105
*/
105106
public static Schema load(final JSONObject schemaJson, final SchemaClient httpClient) {
106107
String schemaId = schemaJson.optString("id");
@@ -455,8 +456,12 @@ private <E> void ifPresent(final String key, final Class<E> expectedType,
455456

456457
/**
457458
* Populates a {@code Schema.Builder} instance from the {@code schemaJson} schema definition.
459+
*
460+
* @return the builder which already contains the validation criteria of the schema, therefore
461+
* {@link Schema.Builder#build()} can be immediately used to acquire the {@link Schema}
462+
* instance to be used for validation
458463
*/
459-
public Schema.Builder<?> load() {
464+
private Schema.Builder<?> load() {
460465
Schema.Builder<?> builder;
461466
if (schemaJson.has("enum")) {
462467
builder = buildEnumSchema();

0 commit comments

Comments
 (0)