Skip to content

Commit

Permalink
Code formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
slisaasquatch committed Jan 5, 2024
1 parent 99fa1b7 commit bb77836
Show file tree
Hide file tree
Showing 13 changed files with 24 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,23 @@ 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);
}

/**
* @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);
}

/**
* @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() {
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/com/saasquatch/jsonschemainferrer/Consts.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ interface Consts {
* Field names
*/
interface Fields {

String TYPE = "type";
String ITEMS = "items";
String ANY_OF = "anyOf";
Expand Down Expand Up @@ -46,6 +47,7 @@ interface Fields {
* Type names
*/
interface Types {

String OBJECT = "object";
String ARRAY = "array";
String STRING = "string";
Expand All @@ -61,6 +63,7 @@ interface Types {
* Format names
*/
interface Formats {

String EMAIL = "email";
String IPV4 = "ipv4";
String IPV6 = "ipv6";
Expand All @@ -70,6 +73,7 @@ interface Formats {
}

interface JsonPath {

String ROOT = "$";
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ public interface EnumExtractor {

/**
* @return The <em>group</em> 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<Collection<? extends JsonNode>> extractEnums(@Nonnull EnumExtractorInput input);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 <E extends Enum<E>> EnumExtractor validEnum(@Nonnull Class<E> enumClass) {
Objects.requireNonNull(enumClass);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
*/
public final class MultipleOfPolicies {

private MultipleOfPolicies() {}
private MultipleOfPolicies() {
}

/**
* @return a singleton {@link MultipleOfPolicy} that does nothing.
Expand All @@ -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 -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ public ObjectNode getFeatureResult(@Nonnull GenericSchemaFeatureInput input) {
})
.orElse(null);
}
},;
},
;

private static final Comparator<JsonNode> NUM_VALUE_COMPARATOR =
Comparator.comparing(JsonNode::decimalValue);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ 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);
}

/**
* @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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit bb77836

Please sign in to comment.