Skip to content

Commit 8c79af2

Browse files
committed
feeding our precious checkstyle rules
1 parent 4b85cee commit 8c79af2

File tree

3 files changed

+22
-4
lines changed

3 files changed

+22
-4
lines changed

core/src/main/java/org/everit/json/schema/Format.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717

1818
import java.util.Arrays;
1919

20+
/**
21+
* Represents a JSON Schema keyword applicable as a "format" value.
22+
*/
2023
public enum Format {
2124

2225
DATE_TIME {
@@ -68,6 +71,10 @@ public String toString() {
6871

6972
};
7073

74+
/**
75+
* Looks up a format instance by its name used in the json schema spec (like "date-time",
76+
* "hostname", "ipv6" etc).
77+
*/
7178
public static Format forName(final String name) {
7279
return Arrays.stream(Format.values())
7380
.filter(fmt -> fmt.toString().equals(name))

core/src/main/java/org/everit/json/schema/FormatValidator.java

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

2020
import org.everit.json.schema.internal.DefaultFormatValidator;
2121

22+
/**
23+
* Implementations perform the validation against the "format" keyword (see JSON Schema spec section
24+
* 7).
25+
*/
2226
@FunctionalInterface
2327
public interface FormatValidator {
2428

2529
/**
26-
* No-operation implementation (never throws {@link ValidationException}).
30+
* No-operation implementation (never throws {always returns {@link Optional#empty()}).
2731
*/
28-
public static final FormatValidator NONE = (subject, format) -> Optional.empty();
32+
FormatValidator NONE = (subject, format) -> Optional.empty();
2933

30-
public static FormatValidator DEFAULT = new DefaultFormatValidator();
34+
FormatValidator DEFAULT = new DefaultFormatValidator();
3135

3236
Optional<String> validate(String subject, Format format);
3337

core/src/main/java/org/everit/json/schema/internal/DefaultFormatValidator.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@
3030
import com.google.common.net.InetAddresses;
3131
import com.google.common.net.InternetDomainName;
3232

33+
/**
34+
* Default implementation of {@link FormatValidator}.
35+
*/
3336
public class DefaultFormatValidator implements FormatValidator {
3437

3538
private static final int IPV4_LENGTH = 4;
@@ -86,7 +89,7 @@ private Optional<String> checkIpAddress(final String subject, final int expected
8689
final String failureFormat) {
8790
return asInetAddress(subject)
8891
.filter(addr -> addr.getAddress().length == expectedLength)
89-
.map(addr -> Optional.<String> empty())
92+
.map(addr -> emptyString())
9093
.orElse(Optional.of(String.format(failureFormat, subject)));
9194
}
9295

@@ -99,6 +102,10 @@ private Optional<String> checkURI(final String subject) {
99102
}
100103
}
101104

105+
private Optional<String> emptyString() {
106+
return Optional.empty();
107+
}
108+
102109
@Override
103110
public Optional<String> validate(final String subject, final Format format) {
104111
Objects.requireNonNull(format, "format cannot be null");

0 commit comments

Comments
 (0)