Skip to content

Commit 68fbdbc

Browse files
authored
Merge pull request #267 from networknt/issue266
fixes #266 reformat the code and resolve javadoc warnnings
2 parents 83a09fd + f227b96 commit 68fbdbc

File tree

299 files changed

+27482
-22249
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

299 files changed

+27482
-22249
lines changed

pom.xml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@
1414
~ limitations under the License.
1515
-->
1616
<project
17-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
18-
xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
17+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
18+
xmlns="http://maven.apache.org/POM/4.0.0"
19+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
1920
<modelVersion>4.0.0</modelVersion>
2021
<groupId>com.networknt</groupId>
2122
<artifactId>json-schema-validator</artifactId>
@@ -245,7 +246,7 @@
245246
<configuration>
246247
<dataFile>${project.build.directory}/coverage-reports/jacoco-ut.exec</dataFile>
247248
<outputDirectory>${project.reporting.outputDirectory}/jacoco-ut</outputDirectory>
248-
</configuration>
249+
</configuration>
249250
</execution>
250251
<!-- End Executions for unit tests -->
251252
<!-- The Executions for integration tests -->
@@ -322,15 +323,16 @@
322323
</goals>
323324
<configuration>
324325
<dataFile>${project.build.directory}/coverage-reports/aggregate.exec</dataFile>
325-
<outputDirectory>${project.reporting.outputDirectory}/jacoco-aggregate</outputDirectory>
326+
<outputDirectory>${project.reporting.outputDirectory}/jacoco-aggregate
327+
</outputDirectory>
326328
</configuration>
327329
</execution>
328330
<!-- End Executions for merging -->
329331
</executions>
330332
</plugin>
331333
</plugins>
332334
</build>
333-
</profile>
335+
</profile>
334336
<profile>
335337
<id>release-sign-artifacts</id>
336338
<activation>

src/main/java/com/networknt/schema/AbstractFormat.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,24 +16,24 @@
1616

1717
package com.networknt.schema;
1818

19-
public abstract class AbstractFormat implements Format{
19+
public abstract class AbstractFormat implements Format {
2020
private final String name;
2121
private final String errorMessageDescription;
22-
22+
2323
public AbstractFormat(String name) {
2424
this(name, "");
2525
}
26-
26+
2727
public AbstractFormat(String name, String errorMessageDescription) {
2828
this.name = name;
2929
this.errorMessageDescription = errorMessageDescription;
3030
}
31-
31+
3232
@Override
3333
public String getName() {
3434
return name;
3535
}
36-
36+
3737
@Override
3838
public String getErrorMessageDescription() {
3939
return errorMessageDescription;

src/main/java/com/networknt/schema/AbstractJsonValidator.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,37 +16,40 @@
1616

1717
package com.networknt.schema;
1818

19+
import com.fasterxml.jackson.databind.JsonNode;
20+
1921
import java.util.Collections;
2022
import java.util.Map;
2123
import java.util.Set;
2224

23-
import com.fasterxml.jackson.databind.JsonNode;
24-
2525
public abstract class AbstractJsonValidator implements JsonValidator {
2626
private final String keyword;
27+
2728
protected AbstractJsonValidator(String keyword) {
2829
this.keyword = keyword;
2930
}
31+
3032
public Set<ValidationMessage> validate(JsonNode node) {
3133
return validate(node, node, AT_ROOT);
3234
}
33-
35+
3436
protected ValidationMessage buildValidationMessage(ErrorMessageType errorMessageType, String at, String... arguments) {
3537
return ValidationMessage.of(keyword, errorMessageType, at, arguments);
3638
}
39+
3740
protected ValidationMessage buildValidationMessage(ErrorMessageType errorMessageType, String at, Map<String, Object> details) {
3841
return ValidationMessage.of(keyword, errorMessageType, at, details);
3942
}
4043

4144
protected Set<ValidationMessage> pass() {
4245
return Collections.emptySet();
4346
}
44-
47+
4548
protected Set<ValidationMessage> fail(ErrorMessageType errorMessageType, String at, Map<String, Object> details) {
4649
return Collections.singleton(buildValidationMessage(errorMessageType, at, details));
4750
}
48-
49-
protected Set<ValidationMessage> fail(ErrorMessageType errorMessageType, String at, String...arguments) {
51+
52+
protected Set<ValidationMessage> fail(ErrorMessageType errorMessageType, String at, String... arguments) {
5053
return Collections.singleton(buildValidationMessage(errorMessageType, at, arguments));
5154
}
5255
}

src/main/java/com/networknt/schema/AbstractKeyword.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@
1919

2020
public abstract class AbstractKeyword implements Keyword {
2121
private final String value;
22-
22+
2323
public AbstractKeyword(String value) {
2424
this.value = value;
2525
}
26-
26+
2727
public String getValue() {
2828
return value;
2929
}
30-
30+
3131
}

src/main/java/com/networknt/schema/AdditionalPropertiesValidator.java

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,13 @@
1616

1717
package com.networknt.schema;
1818

19-
import java.util.ArrayList;
20-
import java.util.Collections;
21-
import java.util.HashSet;
22-
import java.util.Iterator;
23-
import java.util.LinkedHashSet;
24-
import java.util.List;
25-
import java.util.Set;
26-
import java.util.regex.Matcher;
27-
import java.util.regex.Pattern;
28-
19+
import com.fasterxml.jackson.databind.JsonNode;
2920
import org.slf4j.Logger;
3021
import org.slf4j.LoggerFactory;
3122

32-
import com.fasterxml.jackson.databind.JsonNode;
23+
import java.util.*;
24+
import java.util.regex.Matcher;
25+
import java.util.regex.Pattern;
3326

3427
public class AdditionalPropertiesValidator extends BaseJsonValidator implements JsonValidator {
3528
private static final Logger logger = LoggerFactory.getLogger(AdditionalPropertiesValidator.class);
@@ -40,7 +33,7 @@ public class AdditionalPropertiesValidator extends BaseJsonValidator implements
4033
private final List<Pattern> patternProperties = new ArrayList<Pattern>();
4134

4235
public AdditionalPropertiesValidator(String schemaPath, JsonNode schemaNode, JsonSchema parentSchema,
43-
ValidationContext validationContext) {
36+
ValidationContext validationContext) {
4437
super(schemaPath, schemaNode, parentSchema, ValidatorTypeCode.ADDITIONAL_PROPERTIES, validationContext);
4538
if (schemaNode.isBoolean()) {
4639
allowAdditionalProperties = schemaNode.booleanValue();

src/main/java/com/networknt/schema/AllOfValidator.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,7 @@
2020
import org.slf4j.Logger;
2121
import org.slf4j.LoggerFactory;
2222

23-
import java.util.ArrayList;
24-
import java.util.Collections;
25-
import java.util.LinkedHashSet;
26-
import java.util.List;
27-
import java.util.Set;
23+
import java.util.*;
2824

2925
public class AllOfValidator extends BaseJsonValidator implements JsonValidator {
3026
private static final Logger logger = LoggerFactory.getLogger(AllOfValidator.class);

src/main/java/com/networknt/schema/AnyOfValidator.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,11 @@
1616

1717
package com.networknt.schema;
1818

19-
import java.util.ArrayList;
20-
import java.util.Collections;
21-
import java.util.LinkedHashSet;
22-
import java.util.List;
23-
import java.util.Set;
24-
19+
import com.fasterxml.jackson.databind.JsonNode;
2520
import org.slf4j.Logger;
2621
import org.slf4j.LoggerFactory;
2722

28-
import com.fasterxml.jackson.databind.JsonNode;
23+
import java.util.*;
2924

3025
public class AnyOfValidator extends BaseJsonValidator implements JsonValidator {
3126
private static final Logger logger = LoggerFactory.getLogger(RequiredValidator.class);

src/main/java/com/networknt/schema/BaseJsonValidator.java

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,12 @@
1616

1717
package com.networknt.schema;
1818

19-
import java.net.URI;
20-
import java.util.Set;
21-
19+
import com.fasterxml.jackson.databind.JsonNode;
2220
import org.apache.commons.lang3.StringUtils;
2321
import org.slf4j.Logger;
2422

25-
import com.fasterxml.jackson.databind.JsonNode;
23+
import java.net.URI;
24+
import java.util.Set;
2625

2726
public abstract class BaseJsonValidator implements JsonValidator {
2827
private String schemaPath;
@@ -44,9 +43,9 @@ public abstract class BaseJsonValidator implements JsonValidator {
4443

4544
public BaseJsonValidator(String schemaPath, JsonNode schemaNode, JsonSchema parentSchema,
4645
ValidatorTypeCode validatorType, ValidationContext validationContext) {
47-
this(schemaPath, schemaNode, parentSchema, validatorType, false ,
48-
validationContext.getConfig() != null && validationContext.getConfig().isFailFast());
49-
this.config = validationContext.getConfig() == null ? new SchemaValidatorsConfig() : validationContext.getConfig();
46+
this(schemaPath, schemaNode, parentSchema, validatorType, false,
47+
validationContext.getConfig() != null && validationContext.getConfig().isFailFast());
48+
this.config = validationContext.getConfig() == null ? new SchemaValidatorsConfig() : validationContext.getConfig();
5049
}
5150

5251
public BaseJsonValidator(String schemaPath, JsonNode schemaNode, JsonSchema parentSchema,
@@ -78,17 +77,16 @@ protected JsonSchema fetchSubSchemaNode(ValidationContext validationContext) {
7877
}
7978

8079

81-
private static JsonSchema obtainSubSchemaNode(final JsonNode schemaNode, final ValidationContext validationContext){
80+
private static JsonSchema obtainSubSchemaNode(final JsonNode schemaNode, final ValidationContext validationContext) {
8281
final JsonNode node = schemaNode.get("id");
83-
if(node == null) return null;
84-
if(node.equals(schemaNode.get("$schema"))) return null;
82+
if (node == null) return null;
83+
if (node.equals(schemaNode.get("$schema"))) return null;
8584

8685
final String text = node.textValue();
8786
if (text == null) {
8887
return null;
89-
}
90-
else {
91-
final URI uri;
88+
} else {
89+
final URI uri;
9290
try {
9391
uri = validationContext.getURIFactory().create(node.textValue());
9492
} catch (IllegalArgumentException e) {

src/main/java/com/networknt/schema/Collector.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
* Basic interface that allows the implementers to collect the information and
55
* return it.
66
*
7-
* @param <E>
7+
* @param <E> element
88
*/
99
public interface Collector<E> {
1010

11-
public E collect();
11+
public E collect();
1212

1313
}

src/main/java/com/networknt/schema/CollectorContext.java

Lines changed: 45 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -7,54 +7,53 @@
77
/**
88
* Context for holding the output returned by the {@link Collector}
99
* implementations.
10-
*
1110
*/
1211
public class CollectorContext {
1312

14-
static final String COLLECTOR_CONTEXT_THREAD_LOCAL_KEY = "COLLECTOR_CONTEXT_THREAD_LOCAL_KEY";
15-
16-
// Get an instance from thread info (which uses ThreadLocal).
17-
public static CollectorContext getInstance() {
18-
return (CollectorContext) ThreadInfo.get(COLLECTOR_CONTEXT_THREAD_LOCAL_KEY);
19-
}
20-
21-
/**
22-
* Map for holding the collector type and {@link Collector}
23-
*/
24-
private Map<String, Collector<?>> collectorMap = new HashMap<String, Collector<?>>();
25-
26-
/**
27-
* Map for holding the collector type and {@link Collector} class collect method
28-
* output.
29-
*/
30-
private Map<String, Object> collectorLoadMap = new HashMap<String, Object>();
31-
32-
public <E> void add(String collectorType, Collector<E> collector) {
33-
collectorMap.put(collectorType, collector);
34-
}
35-
36-
public Object get(String collectorType) {
37-
if (collectorLoadMap.get(collectorType) == null && collectorMap.get(collectorType) != null) {
38-
collectorLoadMap.put(collectorType, collectorMap.get(collectorType).collect());
39-
}
40-
return collectorLoadMap.get(collectorType);
41-
}
42-
43-
/**
44-
* Load all the collectors associated with the context.
45-
*/
46-
void load() {
47-
for (Entry<String, Collector<?>> collectorEntrySet : collectorMap.entrySet()) {
48-
collectorLoadMap.put(collectorEntrySet.getKey(), collectorEntrySet.getValue().collect());
49-
}
50-
}
51-
52-
/**
53-
* Reset the context
54-
*/
55-
void reset() {
56-
this.collectorMap = new HashMap<String, Collector<?>>();
57-
this.collectorLoadMap = new HashMap<String, Object>();
58-
}
13+
static final String COLLECTOR_CONTEXT_THREAD_LOCAL_KEY = "COLLECTOR_CONTEXT_THREAD_LOCAL_KEY";
14+
15+
// Get an instance from thread info (which uses ThreadLocal).
16+
public static CollectorContext getInstance() {
17+
return (CollectorContext) ThreadInfo.get(COLLECTOR_CONTEXT_THREAD_LOCAL_KEY);
18+
}
19+
20+
/**
21+
* Map for holding the collector type and {@link Collector}
22+
*/
23+
private Map<String, Collector<?>> collectorMap = new HashMap<String, Collector<?>>();
24+
25+
/**
26+
* Map for holding the collector type and {@link Collector} class collect method
27+
* output.
28+
*/
29+
private Map<String, Object> collectorLoadMap = new HashMap<String, Object>();
30+
31+
public <E> void add(String collectorType, Collector<E> collector) {
32+
collectorMap.put(collectorType, collector);
33+
}
34+
35+
public Object get(String collectorType) {
36+
if (collectorLoadMap.get(collectorType) == null && collectorMap.get(collectorType) != null) {
37+
collectorLoadMap.put(collectorType, collectorMap.get(collectorType).collect());
38+
}
39+
return collectorLoadMap.get(collectorType);
40+
}
41+
42+
/**
43+
* Load all the collectors associated with the context.
44+
*/
45+
void load() {
46+
for (Entry<String, Collector<?>> collectorEntrySet : collectorMap.entrySet()) {
47+
collectorLoadMap.put(collectorEntrySet.getKey(), collectorEntrySet.getValue().collect());
48+
}
49+
}
50+
51+
/**
52+
* Reset the context
53+
*/
54+
void reset() {
55+
this.collectorMap = new HashMap<String, Collector<?>>();
56+
this.collectorLoadMap = new HashMap<String, Object>();
57+
}
5958

6059
}

0 commit comments

Comments
 (0)