Skip to content

Commit c1d0837

Browse files
committed
updating to keep java 8 compatibility
1 parent cb248c3 commit c1d0837

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

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

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

1717
package com.networknt.schema;
1818

19+
import java.util.HashSet;
1920
import java.util.Set;
2021

2122
import org.slf4j.Logger;
@@ -39,11 +40,11 @@ public ReadOnlyValidator(String schemaPath, JsonNode schemaNode, JsonSchema pare
3940

4041
public Set<ValidationMessage> validate(JsonNode node, JsonNode rootNode, String at) {
4142
debug(logger, node, rootNode, at);
43+
Set<ValidationMessage> errors= new HashSet<ValidationMessage>();
4244
if (writeMode) {
43-
return Set.of(buildValidationMessage(at));
44-
} else {
45-
return Set.of();
46-
}
45+
errors.add(buildValidationMessage(at));
46+
}
47+
return errors;
4748
}
4849

4950
}

src/test/java/com/networknt/schema/ReadOnlyValidatorTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import java.io.IOException;
88
import java.io.InputStream;
99
import java.util.Set;
10+
import java.util.stream.Collectors;
1011

1112
import org.junit.jupiter.api.Test;
1213

@@ -28,7 +29,7 @@ void givenConfigWriteTrueWhenReadOnlyTrueThenDenies() throws IOException {
2829
Set<ValidationMessage> errors = loadJsonSchema(true).validate(node);
2930
assertFalse(errors.isEmpty());
3031
assertEquals("$.firstName: is a readonly field, it cannot be changed",
31-
errors.stream().map(e -> e.getMessage()).toList().get(0));
32+
errors.stream().map(e -> e.getMessage()).collect(Collectors.toList()).get(0));
3233
}
3334

3435
private JsonSchema loadJsonSchema(Boolean write) {

0 commit comments

Comments
 (0)