Skip to content

Commit 790170c

Browse files
committed
backport 5 of 3000 source lines that prevent compiling for java 1.6
1 parent fcf2fb8 commit 790170c

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

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)