From bb77836d89a636c3e01bd92b3e9e9c5ef9a76cf7 Mon Sep 17 00:00:00 2001 From: slisaasquatch Date: Fri, 5 Jan 2024 10:57:29 -0800 Subject: [PATCH] Code formatting --- .../jsonschemainferrer/AdditionalPropertiesPolicies.java | 6 +++--- src/main/java/com/saasquatch/jsonschemainferrer/Consts.java | 4 ++++ .../com/saasquatch/jsonschemainferrer/EnumExtractor.java | 4 ++-- .../com/saasquatch/jsonschemainferrer/EnumExtractors.java | 2 +- .../com/saasquatch/jsonschemainferrer/ExamplesPolicies.java | 4 ++-- .../saasquatch/jsonschemainferrer/FormatInferrerInput.java | 3 ++- .../com/saasquatch/jsonschemainferrer/FormatInferrers.java | 2 +- .../jsonschemainferrer/GenericSchemaFeatures.java | 3 +-- .../saasquatch/jsonschemainferrer/MultipleOfPolicies.java | 5 +++-- .../saasquatch/jsonschemainferrer/NumberRangeFeature.java | 3 ++- .../com/saasquatch/jsonschemainferrer/RequiredPolicies.java | 4 ++-- .../saasquatch/jsonschemainferrer/StringLengthFeature.java | 2 +- .../com/saasquatch/jsonschemainferrer/JunkDrawerTest.java | 1 - 13 files changed, 24 insertions(+), 19 deletions(-) diff --git a/src/main/java/com/saasquatch/jsonschemainferrer/AdditionalPropertiesPolicies.java b/src/main/java/com/saasquatch/jsonschemainferrer/AdditionalPropertiesPolicies.java index 9ba98b9..a83cd5b 100644 --- a/src/main/java/com/saasquatch/jsonschemainferrer/AdditionalPropertiesPolicies.java +++ b/src/main/java/com/saasquatch/jsonschemainferrer/AdditionalPropertiesPolicies.java @@ -31,7 +31,7 @@ public static AdditionalPropertiesPolicy noOp() { /** * @return A singleton {@link AdditionalPropertiesPolicy} that always sets - * {@code additionalProperties} to true + * {@code additionalProperties} to true */ public static AdditionalPropertiesPolicy allowed() { return input -> JsonNodeFactory.instance.booleanNode(true); @@ -39,7 +39,7 @@ public static AdditionalPropertiesPolicy allowed() { /** * @return A singleton {@link AdditionalPropertiesPolicy} that always sets - * {@code additionalProperties} to false + * {@code additionalProperties} to false */ public static AdditionalPropertiesPolicy notAllowed() { return input -> JsonNodeFactory.instance.booleanNode(false); @@ -47,7 +47,7 @@ public static AdditionalPropertiesPolicy notAllowed() { /** * @return A singleton {@link AdditionalPropertiesPolicy} that sets {@code additionalProperties} - * to existing types on the schema + * to existing types on the schema */ @Beta public static AdditionalPropertiesPolicy existingTypes() { diff --git a/src/main/java/com/saasquatch/jsonschemainferrer/Consts.java b/src/main/java/com/saasquatch/jsonschemainferrer/Consts.java index 168a71d..1f0e734 100644 --- a/src/main/java/com/saasquatch/jsonschemainferrer/Consts.java +++ b/src/main/java/com/saasquatch/jsonschemainferrer/Consts.java @@ -16,6 +16,7 @@ interface Consts { * Field names */ interface Fields { + String TYPE = "type"; String ITEMS = "items"; String ANY_OF = "anyOf"; @@ -46,6 +47,7 @@ interface Fields { * Type names */ interface Types { + String OBJECT = "object"; String ARRAY = "array"; String STRING = "string"; @@ -61,6 +63,7 @@ interface Types { * Format names */ interface Formats { + String EMAIL = "email"; String IPV4 = "ipv4"; String IPV6 = "ipv6"; @@ -70,6 +73,7 @@ interface Formats { } interface JsonPath { + String ROOT = "$"; } diff --git a/src/main/java/com/saasquatch/jsonschemainferrer/EnumExtractor.java b/src/main/java/com/saasquatch/jsonschemainferrer/EnumExtractor.java index 8bbdde1..bd71890 100644 --- a/src/main/java/com/saasquatch/jsonschemainferrer/EnumExtractor.java +++ b/src/main/java/com/saasquatch/jsonschemainferrer/EnumExtractor.java @@ -18,8 +18,8 @@ public interface EnumExtractor { /** * @return The group of enums. Note that each group is expected to be not null and not - * empty. All the elements in each group are expected to come directly from the given - * samples if possible to ensure {@link JsonNode#equals(Object)} works correctly. + * empty. All the elements in each group are expected to come directly from the given samples if + * possible to ensure {@link JsonNode#equals(Object)} works correctly. */ @Nonnull Collection> extractEnums(@Nonnull EnumExtractorInput input); diff --git a/src/main/java/com/saasquatch/jsonschemainferrer/EnumExtractors.java b/src/main/java/com/saasquatch/jsonschemainferrer/EnumExtractors.java index 5d7bb10..3405ed4 100644 --- a/src/main/java/com/saasquatch/jsonschemainferrer/EnumExtractors.java +++ b/src/main/java/com/saasquatch/jsonschemainferrer/EnumExtractors.java @@ -30,7 +30,7 @@ public static EnumExtractor noOp() { /** * @return an {@link EnumExtractor} that extracts all the textual {@link JsonNode}s that are valid - * names of a Java {@link Enum}. + * names of a Java {@link Enum}. */ public static > EnumExtractor validEnum(@Nonnull Class enumClass) { Objects.requireNonNull(enumClass); diff --git a/src/main/java/com/saasquatch/jsonschemainferrer/ExamplesPolicies.java b/src/main/java/com/saasquatch/jsonschemainferrer/ExamplesPolicies.java index 6c4b73b..0b3e2c0 100644 --- a/src/main/java/com/saasquatch/jsonschemainferrer/ExamplesPolicies.java +++ b/src/main/java/com/saasquatch/jsonschemainferrer/ExamplesPolicies.java @@ -34,9 +34,9 @@ public static ExamplesPolicy useFirstSamples(@Nonnegative int limit) { /** * @param typePredicate The predicate for types. Note that the input of this predicate can be - * null. + * null. * @return An {@link ExamplesPolicy} that takes the first samples with a limit and a - * {@link Predicate} for types. + * {@link Predicate} for types. */ @Beta public static ExamplesPolicy useFirstSamples(@Nonnegative int limit, diff --git a/src/main/java/com/saasquatch/jsonschemainferrer/FormatInferrerInput.java b/src/main/java/com/saasquatch/jsonschemainferrer/FormatInferrerInput.java index f3752e1..5631df0 100644 --- a/src/main/java/com/saasquatch/jsonschemainferrer/FormatInferrerInput.java +++ b/src/main/java/com/saasquatch/jsonschemainferrer/FormatInferrerInput.java @@ -14,7 +14,8 @@ public final class FormatInferrerInput { private final SpecVersion specVersion; private final String path; - FormatInferrerInput(@Nonnull JsonNode sample, @Nonnull SpecVersion specVersion, @Nonnull String path) { + FormatInferrerInput(@Nonnull JsonNode sample, @Nonnull SpecVersion specVersion, + @Nonnull String path) { this.sample = sample; this.specVersion = specVersion; this.path = path; diff --git a/src/main/java/com/saasquatch/jsonschemainferrer/FormatInferrers.java b/src/main/java/com/saasquatch/jsonschemainferrer/FormatInferrers.java index df436cc..5b1881a 100644 --- a/src/main/java/com/saasquatch/jsonschemainferrer/FormatInferrers.java +++ b/src/main/java/com/saasquatch/jsonschemainferrer/FormatInferrers.java @@ -46,7 +46,7 @@ public static FormatInferrer ip() { /** * @return A {@link FormatInferrer} that uses the given {@link FormatInferrer}s in the original - * order, and uses the first non-null result available. + * order, and uses the first non-null result available. * @throws NullPointerException if the input has null elements */ public static FormatInferrer chained(@Nonnull FormatInferrer... formatInferrers) { diff --git a/src/main/java/com/saasquatch/jsonschemainferrer/GenericSchemaFeatures.java b/src/main/java/com/saasquatch/jsonschemainferrer/GenericSchemaFeatures.java index 7bbe1ec..8b2d438 100644 --- a/src/main/java/com/saasquatch/jsonschemainferrer/GenericSchemaFeatures.java +++ b/src/main/java/com/saasquatch/jsonschemainferrer/GenericSchemaFeatures.java @@ -24,8 +24,7 @@ public static GenericSchemaFeature noOp() { /** * @return An {@link GenericSchemaFeature} that uses the given {@link GenericSchemaFeature}s in - * the given order, overwriting previous results if add-ons with the same field names - * exist. + * the given order, overwriting previous results if add-ons with the same field names exist. * @throws NullPointerException if the input has null elements */ public static GenericSchemaFeature chained(@Nonnull GenericSchemaFeature... features) { diff --git a/src/main/java/com/saasquatch/jsonschemainferrer/MultipleOfPolicies.java b/src/main/java/com/saasquatch/jsonschemainferrer/MultipleOfPolicies.java index f2f93a8..e7eacba 100644 --- a/src/main/java/com/saasquatch/jsonschemainferrer/MultipleOfPolicies.java +++ b/src/main/java/com/saasquatch/jsonschemainferrer/MultipleOfPolicies.java @@ -10,7 +10,8 @@ */ public final class MultipleOfPolicies { - private MultipleOfPolicies() {} + private MultipleOfPolicies() { + } /** * @return a singleton {@link MultipleOfPolicy} that does nothing. @@ -21,7 +22,7 @@ public static MultipleOfPolicy noOp() { /** * @return a singleton {@link MultipleOfPolicy} that uses the GCD of number samples as - * {@code multipleOf}. + * {@code multipleOf}. */ public static MultipleOfPolicy gcd() { return input -> { diff --git a/src/main/java/com/saasquatch/jsonschemainferrer/NumberRangeFeature.java b/src/main/java/com/saasquatch/jsonschemainferrer/NumberRangeFeature.java index 25e8141..fd61925 100644 --- a/src/main/java/com/saasquatch/jsonschemainferrer/NumberRangeFeature.java +++ b/src/main/java/com/saasquatch/jsonschemainferrer/NumberRangeFeature.java @@ -54,7 +54,8 @@ public ObjectNode getFeatureResult(@Nonnull GenericSchemaFeatureInput input) { }) .orElse(null); } - },; + }, + ; private static final Comparator NUM_VALUE_COMPARATOR = Comparator.comparing(JsonNode::decimalValue); diff --git a/src/main/java/com/saasquatch/jsonschemainferrer/RequiredPolicies.java b/src/main/java/com/saasquatch/jsonschemainferrer/RequiredPolicies.java index 912eecf..7a1db62 100644 --- a/src/main/java/com/saasquatch/jsonschemainferrer/RequiredPolicies.java +++ b/src/main/java/com/saasquatch/jsonschemainferrer/RequiredPolicies.java @@ -26,7 +26,7 @@ public static RequiredPolicy noOp() { /** * @return A singleton {@link RequiredPolicy} that sets {@code required} to field names common to - * the given samples. + * the given samples. */ public static RequiredPolicy commonFields() { return input -> handleCommonFields(input, false); @@ -34,7 +34,7 @@ public static RequiredPolicy commonFields() { /** * @return A singleton {@link RequiredPolicy} that sets {@code required} to field names common to - * the given samples that are not null. + * the given samples that are not null. */ public static RequiredPolicy nonNullCommonFields() { return input -> handleCommonFields(input, true); diff --git a/src/main/java/com/saasquatch/jsonschemainferrer/StringLengthFeature.java b/src/main/java/com/saasquatch/jsonschemainferrer/StringLengthFeature.java index ee44167..467cf4e 100644 --- a/src/main/java/com/saasquatch/jsonschemainferrer/StringLengthFeature.java +++ b/src/main/java/com/saasquatch/jsonschemainferrer/StringLengthFeature.java @@ -22,7 +22,7 @@ public ObjectNode getFeatureResult(@Nonnull GenericSchemaFeatureInput input) { return null; } final ObjectNode result = newObject(); - input.getSamples().stream() + input.getSamples().stream() .mapToInt(JunkDrawer::getSerializedTextLength) .min() .ifPresent(minLength -> result.put(Consts.Fields.MIN_LENGTH, minLength)); diff --git a/src/test/java/com/saasquatch/jsonschemainferrer/JunkDrawerTest.java b/src/test/java/com/saasquatch/jsonschemainferrer/JunkDrawerTest.java index 231ddde..c73a98e 100644 --- a/src/test/java/com/saasquatch/jsonschemainferrer/JunkDrawerTest.java +++ b/src/test/java/com/saasquatch/jsonschemainferrer/JunkDrawerTest.java @@ -12,7 +12,6 @@ import static com.saasquatch.jsonschemainferrer.TestJunkDrawer.jnf; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; import com.fasterxml.jackson.databind.node.ArrayNode;