From 7312b3e4a1cde5d25c1f6b316c5b609bc442c448 Mon Sep 17 00:00:00 2001 From: "zsigmond.czine" Date: Tue, 10 Nov 2015 16:37:25 +0100 Subject: [PATCH] Update OSS parent version. Code format. Fixed checkstyle problems. --- .gitignore | 4 + core/pom.xml | 8 +- .../org/everit/json/schema/EnumSchema.java | 29 +++-- .../json/schema/loader/SchemaLoader.java | 42 ++++--- .../schema/loader/internal/JSONPointer.java | 13 +- pom.xml | 40 +++--- tests/pom.xml | 114 +++++++++--------- 7 files changed, 130 insertions(+), 120 deletions(-) diff --git a/.gitignore b/.gitignore index f69f244b9..8ab15b45f 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,7 @@ .settings .classpath target +.checkstyle +.fbExcludeFilterFile +.pmd +.pmdruleset.xml diff --git a/core/pom.xml b/core/pom.xml index ceb6b7946..a45faf3ab 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -24,7 +24,7 @@ org.everit.config org.everit.config.oss - 7.0.1 + 7.2.0 org.everit.json @@ -32,13 +32,13 @@ 1.0.1 bundle - + json-schema-validator 1.8 1.8 - + Apache License, Version 2.0 @@ -57,7 +57,7 @@ Everit Kft. http://www.everit.org - + scm:git:git://github.com/everit-org/${projectpath}.git scm:git:https://github.com/everit-org/${projectpath}.git diff --git a/core/src/main/java/org/everit/json/schema/EnumSchema.java b/core/src/main/java/org/everit/json/schema/EnumSchema.java index b46a90988..d59f39ddb 100644 --- a/core/src/main/java/org/everit/json/schema/EnumSchema.java +++ b/core/src/main/java/org/everit/json/schema/EnumSchema.java @@ -32,6 +32,11 @@ public static class Builder extends Schema.Builder { private Set possibleValues = new HashSet<>(); + @Override + public EnumSchema build() { + return new EnumSchema(this); + } + public Builder possibleValue(final Object possibleValue) { possibleValues.add(possibleValue); return this; @@ -41,18 +46,21 @@ public Builder possibleValues(final Set possibleValues) { this.possibleValues = possibleValues; return this; } + } - @Override - public EnumSchema build() { - return new EnumSchema(this); - } + public static Builder builder() { + return new Builder(); } private final Set possibleValues; public EnumSchema(final Builder builder) { super(builder); - this.possibleValues = Collections.unmodifiableSet(new HashSet<>(builder.possibleValues)); + possibleValues = Collections.unmodifiableSet(new HashSet<>(builder.possibleValues)); + } + + public Set getPossibleValues() { + return possibleValues; } @Override @@ -61,16 +69,7 @@ public void validate(final Object subject) { .filter(val -> ObjectComparator.deepEquals(val, subject)) .findAny() .orElseThrow( - () -> new ValidationException(String.format("%s is not a valid enum value", - subject))); - } - - public Set getPossibleValues() { - return possibleValues; - } - - public static Builder builder() { - return new Builder(); + () -> new ValidationException(String.format("%s is not a valid enum value", subject))); } } diff --git a/core/src/main/java/org/everit/json/schema/loader/SchemaLoader.java b/core/src/main/java/org/everit/json/schema/loader/SchemaLoader.java index b6fdf1c5a..74f500777 100644 --- a/core/src/main/java/org/everit/json/schema/loader/SchemaLoader.java +++ b/core/src/main/java/org/everit/json/schema/loader/SchemaLoader.java @@ -58,6 +58,9 @@ public class SchemaLoader { /** * Created and used by {@link TypeBasedMultiplexer} to set actions (consumers) for matching * classes. + * + * @param + * the type of the input to the operation. */ @FunctionalInterface interface OnTypeConsumer { @@ -88,7 +91,7 @@ class TypeBasedMultiplexer { */ private class IdModifyingTypeConsumerImpl extends OnTypeConsumerImpl { - public IdModifyingTypeConsumerImpl(final Class key) { + IdModifyingTypeConsumerImpl(final Class key) { super(key); } @@ -118,12 +121,15 @@ public TypeBasedMultiplexer then(final Consumer consumer) { /** * Default implementation of {@link OnTypeConsumer}, instantiated by * {@link TypeBasedMultiplexer#ifIs(Class)}. + * + * @param + * the type of the input to the operation. */ private class OnTypeConsumerImpl implements OnTypeConsumer { protected final Class key; - public OnTypeConsumerImpl(final Class key) { + OnTypeConsumerImpl(final Class key) { this.key = key; } @@ -135,16 +141,16 @@ public TypeBasedMultiplexer then(final Consumer consumer) { } + private final Map, Consumer> actions = new HashMap<>(); + private final String keyOfObj; private final Object obj; - private final Map, Consumer> actions = new HashMap<>(); - /** * Constructor with {@code null} {@code keyOfObj}. */ - public TypeBasedMultiplexer(final Object obj) { + TypeBasedMultiplexer(final Object obj) { this(null, obj); } @@ -158,7 +164,7 @@ public TypeBasedMultiplexer(final Object obj) { * the object which' class is matched against the classes defined by * {@link #ifIs(Class)} (or {@link #ifObject()}) calls. */ - public TypeBasedMultiplexer(final String keyOfObj, final Object obj) { + TypeBasedMultiplexer(final String keyOfObj, final Object obj) { this.keyOfObj = keyOfObj; this.obj = obj; } @@ -227,6 +233,12 @@ public void requireAny() { "maxItems", "uniqueItems"); + private static final Map, CombinedSchema.Builder>> COMBINED_SUBSCHEMA_PROVIDERS = // CS_DISABLE_LINE_LENGTH + new HashMap<>(3); + + private static final List NUMBER_SCHEMA_PROPS = Arrays.asList("minimum", "maximum", + "minimumExclusive", "maximumExclusive", "multipleOf"); + private static final List OBJECT_SCHEMA_PROPS = Arrays.asList("properties", "required", "minProperties", "maxProperties", @@ -234,15 +246,9 @@ public void requireAny() { "patternProperties", "additionalProperties"); - private static final List NUMBER_SCHEMA_PROPS = Arrays.asList("minimum", "maximum", - "minimumExclusive", "maximumExclusive", "multipleOf"); - private static final List STRING_SCHEMA_PROPS = Arrays.asList("minLength", "maxLength", "pattern"); - private static final Map, CombinedSchema.Builder>> // - COMBINED_SUBSCHEMA_PROVIDERS = new HashMap<>(3); - static { COMBINED_SUBSCHEMA_PROVIDERS.put("allOf", CombinedSchema::allOf); COMBINED_SUBSCHEMA_PROVIDERS.put("anyOf", CombinedSchema::anyOf); @@ -258,7 +264,7 @@ public void requireAny() { * @return the schema validator object */ public static Schema load(final JSONObject schemaJson) { - return load(schemaJson, new DefaultSchemaClient()); + return SchemaLoader.load(schemaJson, new DefaultSchemaClient()); } /** @@ -276,15 +282,15 @@ public static Schema load(final JSONObject schemaJson, final SchemaClient httpCl .load().build(); } + private final SchemaClient httpClient; + private String id = null; - private final JSONObject schemaJson; + private final Map pointerSchemas; private final JSONObject rootSchemaJson; - private final SchemaClient httpClient; - - private final Map pointerSchemas; + private final JSONObject schemaJson; /** * Constructor. @@ -405,7 +411,7 @@ private ObjectSchema.Builder buildObjectSchema() { } } } - ifPresent("dependencies", JSONObject.class, deps -> this.addDependencies(builder, deps)); + ifPresent("dependencies", JSONObject.class, deps -> addDependencies(builder, deps)); return builder; } diff --git a/core/src/main/java/org/everit/json/schema/loader/internal/JSONPointer.java b/core/src/main/java/org/everit/json/schema/loader/internal/JSONPointer.java index 56bac11f3..4aa7b62d3 100644 --- a/core/src/main/java/org/everit/json/schema/loader/internal/JSONPointer.java +++ b/core/src/main/java/org/everit/json/schema/loader/internal/JSONPointer.java @@ -47,7 +47,7 @@ public static class QueryResult { /** * Constructor. - * + * * @param containingDocument * the JSON document which contains the query result. * @param queryResult @@ -61,7 +61,7 @@ public QueryResult(final JSONObject containingDocument, final JSONObject queryRe /** * Getter for {@link #containingDocument}. - * + * * @return the JSON document which contains the query result. */ public JSONObject getContainingDocument() { @@ -70,7 +70,7 @@ public JSONObject getContainingDocument() { /** * Getter for {@link #queryResult}. - * + * * @return the JSON object being the result of the query execution. */ public JSONObject getQueryResult() { @@ -138,7 +138,7 @@ public static final JSONPointer forURL(final SchemaClient schemaClient, final St fragment = url.substring(poundIdx); toBeQueried = url.substring(0, poundIdx); } - return new JSONPointer(() -> executeWith(schemaClient, toBeQueried), fragment); + return new JSONPointer(() -> JSONPointer.executeWith(schemaClient, toBeQueried), fragment); } private final Supplier documentProvider; @@ -153,9 +153,10 @@ public JSONPointer(final Supplier documentProvider, final String fra /** * Queries from {@code document} based on this pointer. * + * @return a DTO containing the query result and the root document containing the query result. + * * @throws IllegalArgumentException * if the pointer does not start with {@code '#'}. - * @return a DTO containing the query result and the root document containing the query result */ public QueryResult query() { JSONObject document = documentProvider.get(); @@ -163,7 +164,7 @@ public QueryResult query() { return new QueryResult(document, document); } String[] path = fragment.split("/"); - if (path[0] == null || !path[0].startsWith("#")) { + if ((path[0] == null) || !path[0].startsWith("#")) { throw new IllegalArgumentException("JSON pointers must start with a '#'"); } Object current = document; diff --git a/pom.xml b/pom.xml index 142d26bf1..a8b6b07d4 100644 --- a/pom.xml +++ b/pom.xml @@ -17,25 +17,25 @@ --> - - 4.0.0 - - - org.everit.config - org.everit.config.oss - 7.0.1 - - - org.everit.json - org.everit.json.schema.parent - 1.0.1 - - pom - - - core - tests - + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + + 4.0.0 + + + org.everit.config + org.everit.config.oss + 7.2.0 + + + org.everit.json + org.everit.json.schema.parent + 1.0.1 + + pom + + + core + tests + diff --git a/tests/pom.xml b/tests/pom.xml index 596adafde..33ea66dc6 100644 --- a/tests/pom.xml +++ b/tests/pom.xml @@ -17,65 +17,65 @@ --> + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - 4.0.0 + 4.0.0 - - org.everit.json - org.everit.json.schema.parent - 1.0.1 - - - org.everit.json.schema.tests + + org.everit.json + org.everit.json.schema.parent + 1.0.1 + + + org.everit.json.schema.tests - - - - org.apache.maven.plugins - maven-compiler-plugin - 3.3 - - 1.8 - 1.8 - - - - + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.3 + + 1.8 + 1.8 + + + + - - - org.everit.json - org.everit.json.schema - ${project.version} - - - org.everit.osgi.bundles - org.everit.osgi.bundles.org.json - 1.0.0-v20140107 - - - junit - junit - 4.12 - test - - - org.reflections - reflections - 0.9.10 - test - - - org.eclipse.jetty - jetty-server - 9.3.4.RC0 - test - - - org.eclipse.jetty - jetty-servlet - 9.3.4.RC0 - - + + + org.everit.json + org.everit.json.schema + ${project.version} + + + org.everit.osgi.bundles + org.everit.osgi.bundles.org.json + 1.0.0-v20140107 + + + junit + junit + 4.12 + test + + + org.reflections + reflections + 0.9.10 + test + + + org.eclipse.jetty + jetty-server + 9.3.4.RC0 + test + + + org.eclipse.jetty + jetty-servlet + 9.3.4.RC0 + +