Skip to content

Commit 55794b4

Browse files
committed
upgrade to 1.0.34 and update changelog
1 parent cb338c5 commit 55794b4

24 files changed

+791
-498
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,15 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
99

1010
### Changed
1111

12+
## 1.0.34 - 2020-03-12
13+
14+
### Added
15+
16+
### Changed
17+
18+
- fixes #268 Collector Context changes to handle simple Objects. Thanks @prashanthjos
19+
- fixes #266 reformat the code and resolve javadoc warnnings
20+
1221
## 1.0.33 - 2020-03-09
1322

1423
### Added

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,15 +80,15 @@ Maven:
8080
<dependency>
8181
<groupId>com.networknt</groupId>
8282
<artifactId>json-schema-validator</artifactId>
83-
<version>1.0.33</version>
83+
<version>1.0.34</version>
8484
</dependency>
8585
```
8686

8787
Gradle:
8888

8989
```
9090
dependencies {
91-
compile(group: "com.networknt", name: "json-schema-validator", version: "1.0.33");
91+
compile(group: "com.networknt", name: "json-schema-validator", version: "1.0.34");
9292
}
9393
```
9494

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<modelVersion>4.0.0</modelVersion>
2121
<groupId>com.networknt</groupId>
2222
<artifactId>json-schema-validator</artifactId>
23-
<version>1.0.33</version>
23+
<version>1.0.34</version>
2424
<packaging>bundle</packaging>
2525
<description>A json schema validator that supports draft v4, v6, v7 and v2019-09</description>
2626
<url>https://github.com/networknt/json-schema-validator</url>
Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,24 @@
1+
/*
2+
* Copyright (c) 2020 Network New Technologies Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
116
package com.networknt.schema;
217

3-
public abstract class AbstractCollector<E> implements Collector<E>{
18+
public abstract class AbstractCollector<E> implements Collector<E> {
419

5-
@Override
6-
public void combine(Object object) {
7-
// Do nothing. This is the default Implementation.
8-
}
20+
@Override
21+
public void combine(Object object) {
22+
// Do nothing. This is the default Implementation.
23+
}
924
}
Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
/*
2+
* Copyright (c) 2020 Network New Technologies Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
117
package com.networknt.schema;
218

319
/**
@@ -9,20 +25,22 @@
925
public interface Collector<E> {
1026

1127

12-
/**
13-
* This method should be called by the intermediate touch points that want to
14-
* combine the data being collected by this collector. This is an optional
15-
* method and could be used when the same collector is used for collecting data
16-
* at multiple touch points or accumulating data at same touch point.
17-
*/
18-
public void combine(Object object);
28+
/**
29+
* This method should be called by the intermediate touch points that want to
30+
* combine the data being collected by this collector. This is an optional
31+
* method and could be used when the same collector is used for collecting data
32+
* at multiple touch points or accumulating data at same touch point.
33+
* @param object Object
34+
*/
35+
public void combine(Object object);
1936

20-
/**
21-
* Final method called by the framework that returns the actual collected data.
22-
* If the collector is not accumulating data or being used to collect data at
23-
* multiple touch points, only this method can be implemented.
24-
*/
25-
public E collect();
37+
/**
38+
* Final method called by the framework that returns the actual collected data.
39+
* If the collector is not accumulating data or being used to collect data at
40+
* multiple touch points, only this method can be implemented.
41+
* @return E element
42+
*/
43+
public E collect();
2644

2745

2846
}
Lines changed: 102 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
/*
2+
* Copyright (c) 2020 Network New Technologies Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
116
package com.networknt.schema;
217

318
import java.util.HashMap;
@@ -11,105 +26,102 @@
1126
*/
1227
public class CollectorContext {
1328

14-
// Using a namespace string as key in ThreadLocal so that it is unique in
15-
// ThreadLocal.
16-
static final String COLLECTOR_CONTEXT_THREAD_LOCAL_KEY = "com.networknt.schema.CollectorKey";
29+
// Using a namespace string as key in ThreadLocal so that it is unique in
30+
// ThreadLocal.
31+
static final String COLLECTOR_CONTEXT_THREAD_LOCAL_KEY = "com.networknt.schema.CollectorKey";
1732

18-
// Get an instance from thread info (which uses ThreadLocal).
19-
public static CollectorContext getInstance() {
20-
return (CollectorContext) ThreadInfo.get(COLLECTOR_CONTEXT_THREAD_LOCAL_KEY);
21-
}
33+
// Get an instance from thread info (which uses ThreadLocal).
34+
public static CollectorContext getInstance() {
35+
return (CollectorContext) ThreadInfo.get(COLLECTOR_CONTEXT_THREAD_LOCAL_KEY);
36+
}
2237

23-
/**
24-
* Map for holding the name and {@link Collector} or a simple Object.
25-
*/
26-
private Map<String, Object> collectorMap = new HashMap<String, Object>();
38+
/**
39+
* Map for holding the name and {@link Collector} or a simple Object.
40+
*/
41+
private Map<String, Object> collectorMap = new HashMap<String, Object>();
2742

28-
/**
29-
* Map for holding the name and {@link Collector} class collect method output.
30-
*/
31-
private Map<String, Object> collectorLoadMap = new HashMap<String, Object>();
43+
/**
44+
* Map for holding the name and {@link Collector} class collect method output.
45+
*/
46+
private Map<String, Object> collectorLoadMap = new HashMap<String, Object>();
3247

33-
/**
34-
*
35-
* Adds a collector with give name. Preserving this method for backward
36-
* compatibility.
37-
*
38-
* @param <E>
39-
* @param name
40-
* @param collector
41-
*/
42-
public <E> void add(String name, Collector<E> collector) {
43-
collectorMap.put(name, collector);
44-
}
48+
/**
49+
* Adds a collector with give name. Preserving this method for backward
50+
* compatibility.
51+
*
52+
* @param <E> element
53+
* @param name String
54+
* @param collector Collector
55+
*/
56+
public <E> void add(String name, Collector<E> collector) {
57+
collectorMap.put(name, collector);
58+
}
4559

46-
/**
47-
*
48-
* Adds a collector or a simple object with give name.
49-
*
50-
* @param <E>
51-
* @param name
52-
* @param collector
53-
*/
54-
public <E> void add(String name, Object object) {
55-
collectorMap.put(name, object);
56-
}
60+
/**
61+
* Adds a collector or a simple object with give name.
62+
*
63+
* @param <E> element
64+
* @param object Object
65+
* @param name String
66+
*
67+
*/
68+
public <E> void add(String name, Object object) {
69+
collectorMap.put(name, object);
70+
}
5771

58-
/**
59-
*
60-
* Gets the data associated with a given name. Please note if you are using a
61-
* Collector you should wait till the validation is complete to gather all data.
62-
*
63-
* For a Collector, this method will return the collector as long as load method
64-
* is not called. Once the load method is called this method will return the
65-
* actual data collected by collector.
66-
*
67-
* @param name
68-
* @return
69-
*/
70-
public Object get(String name) {
71-
Object object = collectorMap.get(name);
72-
if (object instanceof Collector<?> && (collectorLoadMap.get(name) != null)) {
73-
return collectorLoadMap.get(name);
74-
}
75-
return collectorMap.get(name);
76-
}
72+
/**
73+
* Gets the data associated with a given name. Please note if you are using a
74+
* Collector you should wait till the validation is complete to gather all data.
75+
* <p>
76+
* For a Collector, this method will return the collector as long as load method
77+
* is not called. Once the load method is called this method will return the
78+
* actual data collected by collector.
79+
*
80+
* @param name String
81+
* @return Object
82+
*/
83+
public Object get(String name) {
84+
Object object = collectorMap.get(name);
85+
if (object instanceof Collector<?> && (collectorLoadMap.get(name) != null)) {
86+
return collectorLoadMap.get(name);
87+
}
88+
return collectorMap.get(name);
89+
}
7790

78-
/**
79-
*
80-
* Combines data with Collector identified by the given name.
81-
*
82-
* @param name
83-
* @param data
84-
*/
85-
public void combineWithCollector(String name, Object data) {
86-
Object object = collectorMap.get(name);
87-
if (object instanceof Collector<?>) {
88-
Collector<?> collector = (Collector<?>) object;
89-
collector.combine(data);
90-
}
91-
}
91+
/**
92+
* Combines data with Collector identified by the given name.
93+
*
94+
* @param name String
95+
* @param data Object
96+
*/
97+
public void combineWithCollector(String name, Object data) {
98+
Object object = collectorMap.get(name);
99+
if (object instanceof Collector<?>) {
100+
Collector<?> collector = (Collector<?>) object;
101+
collector.combine(data);
102+
}
103+
}
92104

93-
/**
94-
* Reset the context
95-
*/
96-
void reset() {
97-
this.collectorMap = new HashMap<String, Object>();
98-
this.collectorLoadMap = new HashMap<String, Object>();
99-
}
105+
/**
106+
* Reset the context
107+
*/
108+
void reset() {
109+
this.collectorMap = new HashMap<String, Object>();
110+
this.collectorLoadMap = new HashMap<String, Object>();
111+
}
100112

101-
/**
102-
* Loads data from all collectors.
103-
*/
104-
void loadCollectors() {
105-
Set<Entry<String, Object>> entrySet = collectorMap.entrySet();
106-
for (Entry<String, Object> entry : entrySet) {
107-
if (entry.getValue() instanceof Collector<?>) {
108-
Collector<?> collector = (Collector<?>) entry.getValue();
109-
collectorLoadMap.put(entry.getKey(), collector.collect());
110-
}
111-
}
113+
/**
114+
* Loads data from all collectors.
115+
*/
116+
void loadCollectors() {
117+
Set<Entry<String, Object>> entrySet = collectorMap.entrySet();
118+
for (Entry<String, Object> entry : entrySet) {
119+
if (entry.getValue() instanceof Collector<?>) {
120+
Collector<?> collector = (Collector<?>) entry.getValue();
121+
collectorLoadMap.put(entry.getKey(), collector.collect());
122+
}
123+
}
112124

113-
}
125+
}
114126

115127
}

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
/*
2+
* Copyright (c) 2020 Network New Technologies Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
116
package com.networknt.schema;
217

318
import com.fasterxml.jackson.databind.JsonNode;

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
/*
2+
* Copyright (c) 2020 Network New Technologies Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
116
package com.networknt.schema;
217

318
import com.fasterxml.jackson.databind.JsonNode;

0 commit comments

Comments
 (0)