Skip to content

Commit 5978b34

Browse files
authored
Merge pull request #38 from basinilya/basin
Don't leave out 50% of your audience who still use older java
2 parents fcf2fb8 + 9e37ab5 commit 5978b34

File tree

2 files changed

+28
-9
lines changed

2 files changed

+28
-9
lines changed

pom.xml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@
6363
</distributionManagement>
6464

6565
<properties>
66-
<java.version>1.8</java.version>
66+
<java.version>1.6</java.version>
67+
<java.testversion>1.7</java.testversion>
6768
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
6869
<version.jackson>2.8.7</version.jackson>
6970
<version.slf4j>1.7.25</version.slf4j>
@@ -206,6 +207,19 @@
206207
<source>${java.version}</source>
207208
<target>${java.version}</target>
208209
</configuration>
210+
<executions>
211+
<execution>
212+
<id>test-compile</id>
213+
<phase>process-test-sources</phase>
214+
<goals>
215+
<goal>testCompile</goal>
216+
</goals>
217+
<configuration>
218+
<source>${java.testversion}</source>
219+
<target>${java.testversion}</target>
220+
</configuration>
221+
</execution>
222+
</executions>
209223
</plugin>
210224

211225
<plugin>

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

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,15 @@
1818

1919
import com.fasterxml.jackson.databind.JsonNode;
2020
import com.fasterxml.jackson.databind.ObjectMapper;
21+
2122
import org.slf4j.Logger;
2223
import org.slf4j.LoggerFactory;
2324

2425
import java.util.ArrayList;
2526
import java.util.HashSet;
27+
import java.util.Iterator;
2628
import java.util.List;
2729
import java.util.Set;
28-
import java.util.stream.Collectors;
2930

3031
public class OneOfValidator extends BaseJsonValidator implements JsonValidator {
3132
private static final Logger logger = LoggerFactory.getLogger(RequiredValidator.class);
@@ -46,13 +47,13 @@ public Set<ValidationMessage> validate(JsonNode node, JsonNode rootNode, String
4647
debug(logger, node, rootNode, at);
4748

4849
int numberOfValidSchema = 0;
49-
Set<ValidationMessage> errors = new HashSet<>();
50+
Set<ValidationMessage> errors = new HashSet<ValidationMessage>();
5051

5152
for (JsonSchema schema : schemas) {
5253
Set<ValidationMessage> schemaErrors = schema.validate(node, rootNode, at);
5354
if (schemaErrors.isEmpty()) {
5455
numberOfValidSchema++;
55-
errors = new HashSet<>();
56+
errors = new HashSet<ValidationMessage>();
5657
}
5758
if(numberOfValidSchema == 0){
5859
errors.addAll(schemaErrors);
@@ -63,13 +64,17 @@ public Set<ValidationMessage> validate(JsonNode node, JsonNode rootNode, String
6364
}
6465

6566
if (numberOfValidSchema == 0) {
66-
errors = errors.stream()
67-
.filter(msg -> !ValidatorTypeCode.ADDITIONAL_PROPERTIES
68-
.equals(ValidatorTypeCode.fromValue(msg.getType())))
69-
.collect(Collectors.toSet());
67+
for (Iterator<ValidationMessage> it = errors.iterator(); it.hasNext();) {
68+
ValidationMessage msg = it.next();
69+
70+
if (ValidatorTypeCode.ADDITIONAL_PROPERTIES.equals(ValidatorTypeCode.fromValue(msg
71+
.getType()))) {
72+
it.remove();
73+
}
74+
}
7075
}
7176
if (numberOfValidSchema > 1) {
72-
errors = new HashSet<>();
77+
errors = new HashSet<ValidationMessage>();
7378
errors.add(buildValidationMessage(at, ""));
7479
}
7580

0 commit comments

Comments
 (0)