From 20ac321df6b9e223d280b22ee55204bba86a74ef Mon Sep 17 00:00:00 2001 From: rabbitvirus Date: Wed, 26 Jan 2022 22:36:59 +0100 Subject: [PATCH] Constants and instantiation problems fix --- .../java/graphql/scalars/ExtendedScalars.java | 32 +++++++++---------- .../graphql/scalars/alias/AliasedScalar.java | 4 ++- .../graphql/scalars/datetime/DateScalar.java | 12 ++++--- .../scalars/datetime/DateTimeScalar.java | 6 ++-- .../scalars/datetime/LocalTimeCoercing.java | 6 ++-- .../graphql/scalars/datetime/TimeScalar.java | 8 +++-- .../graphql/scalars/java/JavaPrimitives.java | 4 ++- .../graphql/scalars/locale/LocaleScalar.java | 6 ++-- .../scalars/numeric/FloatCoercing.java | 2 +- .../graphql/scalars/numeric/IntCoercing.java | 2 +- .../scalars/numeric/NegativeFloatScalar.java | 8 +++-- .../scalars/numeric/NegativeIntScalar.java | 8 +++-- .../numeric/NonNegativeFloatScalar.java | 8 +++-- .../scalars/numeric/NonNegativeIntScalar.java | 8 +++-- .../numeric/NonPositiveFloatScalar.java | 9 ++++-- .../scalars/numeric/NonPositiveIntScalar.java | 9 ++++-- .../scalars/numeric/PositiveFloatScalar.java | 9 ++++-- .../scalars/numeric/PositiveIntScalar.java | 8 +++-- .../graphql/scalars/object/JsonScalar.java | 6 ++-- .../graphql/scalars/object/ObjectScalar.java | 6 ++-- .../graphql/scalars/regex/RegexScalar.java | 4 ++- .../java/graphql/scalars/url/UrlScalar.java | 6 ++-- 22 files changed, 105 insertions(+), 66 deletions(-) diff --git a/src/main/java/graphql/scalars/ExtendedScalars.java b/src/main/java/graphql/scalars/ExtendedScalars.java index 6ea2ac9..e1df3d4 100644 --- a/src/main/java/graphql/scalars/ExtendedScalars.java +++ b/src/main/java/graphql/scalars/ExtendedScalars.java @@ -40,7 +40,7 @@ public class ExtendedScalars { * @see java.time.OffsetDateTime * @see java.time.ZonedDateTime */ - public static GraphQLScalarType DateTime = DateTimeScalar.INSTANCE; + public static final GraphQLScalarType DateTime = DateTimeScalar.INSTANCE; /** * An RFC-3339 compliant date scalar that accepts string values like `1996-12-19` and produces @@ -53,7 +53,7 @@ public class ExtendedScalars { * * @see java.time.LocalDate */ - public static GraphQLScalarType Date = DateScalar.INSTANCE; + public static final GraphQLScalarType Date = DateScalar.INSTANCE; /** * An RFC-3339 compliant time scalar that accepts string values like `6:39:57-08:00` and produces * `java.time.OffsetTime` objects at runtime. @@ -65,7 +65,7 @@ public class ExtendedScalars { * * @see java.time.OffsetTime */ - public static GraphQLScalarType Time = TimeScalar.INSTANCE; + public static final GraphQLScalarType Time = TimeScalar.INSTANCE; /** * A 24-hour local time scalar that accepts strings like `hh:mm:ss` and `hh:mm:ss.sss` and produces @@ -76,7 +76,7 @@ public class ExtendedScalars { * * @see java.time.LocalTime */ - public static GraphQLScalarType LocalTime = GraphQLScalarType.newScalar() + public static final GraphQLScalarType LocalTime = GraphQLScalarType.newScalar() .name("LocalTime") .description("24-hour clock time value string in the format `hh:mm:ss` or `hh:mm:ss.sss`.") .coercing(new LocalTimeCoercing()) @@ -105,7 +105,7 @@ public class ExtendedScalars { * * @see #Json */ - public static GraphQLScalarType Object = ObjectScalar.INSTANCE; + public static final GraphQLScalarType Object = ObjectScalar.INSTANCE; /** * A synonym class for the {@link #Object} scalar, since some people prefer their SDL to look like the following : @@ -122,68 +122,68 @@ public class ExtendedScalars { * * @see graphql.scalars.ExtendedScalars#Object */ - public static GraphQLScalarType Json = JsonScalar.INSTANCE; + public static final GraphQLScalarType Json = JsonScalar.INSTANCE; /** * A URL scalar that accepts URL strings and produces {@link java.net.URL} objects at runtime */ - public static GraphQLScalarType Url = UrlScalar.INSTANCE; + public static final GraphQLScalarType Url = UrlScalar.INSTANCE; /** * A Locale scalar that accepts a IETF BCP 47 language tag string and produces {@link * java.util.Locale} objects at runtime. */ - public static GraphQLScalarType Locale = LocaleScalar.INSTANCE; + public static final GraphQLScalarType Locale = LocaleScalar.INSTANCE; /** * An `Int` scalar that MUST be greater than zero * * @see graphql.Scalars#GraphQLInt */ - public static GraphQLScalarType PositiveInt = PositiveIntScalar.INSTANCE; + public static final GraphQLScalarType PositiveInt = PositiveIntScalar.INSTANCE; /** * An `Int` scalar that MUST be less than zero * * @see graphql.Scalars#GraphQLInt */ - public static GraphQLScalarType NegativeInt = NegativeIntScalar.INSTANCE; + public static final GraphQLScalarType NegativeInt = NegativeIntScalar.INSTANCE; /** * An `Int` scalar that MUST be less than or equal to zero * * @see graphql.Scalars#GraphQLInt */ - public static GraphQLScalarType NonPositiveInt = NonPositiveIntScalar.INSTANCE; + public static final GraphQLScalarType NonPositiveInt = NonPositiveIntScalar.INSTANCE; /** * An `Int` scalar that MUST be greater than or equal to zero * * @see graphql.Scalars#GraphQLInt */ - public static GraphQLScalarType NonNegativeInt = NonNegativeIntScalar.INSTANCE; + public static final GraphQLScalarType NonNegativeInt = NonNegativeIntScalar.INSTANCE; /** * An `Float` scalar that MUST be greater than zero * * @see graphql.Scalars#GraphQLFloat */ - public static GraphQLScalarType PositiveFloat = PositiveFloatScalar.INSTANCE; + public static final GraphQLScalarType PositiveFloat = PositiveFloatScalar.INSTANCE; /** * An `Float` scalar that MUST be less than zero * * @see graphql.Scalars#GraphQLFloat */ - public static GraphQLScalarType NegativeFloat = NegativeFloatScalar.INSTANCE; + public static final GraphQLScalarType NegativeFloat = NegativeFloatScalar.INSTANCE; /** * An `Float` scalar that MUST be less than or equal to zero * * @see graphql.Scalars#GraphQLFloat */ - public static GraphQLScalarType NonPositiveFloat = NonPositiveFloatScalar.INSTANCE; + public static final GraphQLScalarType NonPositiveFloat = NonPositiveFloatScalar.INSTANCE; /** * An `Float` scalar that MUST be greater than or equal to zero * * @see graphql.Scalars#GraphQLFloat */ - public static GraphQLScalarType NonNegativeFloat = NonNegativeFloatScalar.INSTANCE; + public static final GraphQLScalarType NonNegativeFloat = NonNegativeFloatScalar.INSTANCE; /** diff --git a/src/main/java/graphql/scalars/alias/AliasedScalar.java b/src/main/java/graphql/scalars/alias/AliasedScalar.java index 903c754..9f7ba58 100644 --- a/src/main/java/graphql/scalars/alias/AliasedScalar.java +++ b/src/main/java/graphql/scalars/alias/AliasedScalar.java @@ -15,7 +15,9 @@ * Access this via {@link graphql.scalars.ExtendedScalars#newAliasedScalar(String)} */ @Internal -public class AliasedScalar { +public final class AliasedScalar { + + private AliasedScalar() {} /** * A builder for {@link graphql.scalars.alias.AliasedScalar} diff --git a/src/main/java/graphql/scalars/datetime/DateScalar.java b/src/main/java/graphql/scalars/datetime/DateScalar.java index bba22aa..592f04e 100644 --- a/src/main/java/graphql/scalars/datetime/DateScalar.java +++ b/src/main/java/graphql/scalars/datetime/DateScalar.java @@ -22,11 +22,13 @@ * Access this via {@link graphql.scalars.ExtendedScalars#Date} */ @Internal -public class DateScalar { +public final class DateScalar { - private final static DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + private static final DateTimeFormatter DATE_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd"); - public static GraphQLScalarType INSTANCE; + public static final GraphQLScalarType INSTANCE; + + private DateScalar() {} static { Coercing coercing = new Coercing() { @@ -43,7 +45,7 @@ public String serialize(Object input) throws CoercingSerializeException { ); } try { - return dateFormatter.format(temporalAccessor); + return DATE_FORMATTER.format(temporalAccessor); } catch (DateTimeException e) { throw new CoercingSerializeException( "Unable to turn TemporalAccessor into full date because of : '" + e.getMessage() + "'." @@ -90,7 +92,7 @@ public Value valueToLiteral(Object input) { private LocalDate parseLocalDate(String s, Function exceptionMaker) { try { - TemporalAccessor temporalAccessor = dateFormatter.parse(s); + TemporalAccessor temporalAccessor = DATE_FORMATTER.parse(s); return LocalDate.from(temporalAccessor); } catch (DateTimeParseException e) { throw exceptionMaker.apply("Invalid RFC3339 full date value : '" + s + "'. because of : '" + e.getMessage() + "'"); diff --git a/src/main/java/graphql/scalars/datetime/DateTimeScalar.java b/src/main/java/graphql/scalars/datetime/DateTimeScalar.java index 631c611..20fd345 100644 --- a/src/main/java/graphql/scalars/datetime/DateTimeScalar.java +++ b/src/main/java/graphql/scalars/datetime/DateTimeScalar.java @@ -22,9 +22,11 @@ * Access this via {@link graphql.scalars.ExtendedScalars#DateTime} */ @Internal -public class DateTimeScalar { +public final class DateTimeScalar { - public static GraphQLScalarType INSTANCE; + public static final GraphQLScalarType INSTANCE; + + private DateTimeScalar() {} static { Coercing coercing = new Coercing() { diff --git a/src/main/java/graphql/scalars/datetime/LocalTimeCoercing.java b/src/main/java/graphql/scalars/datetime/LocalTimeCoercing.java index e0345cb..4c5666d 100644 --- a/src/main/java/graphql/scalars/datetime/LocalTimeCoercing.java +++ b/src/main/java/graphql/scalars/datetime/LocalTimeCoercing.java @@ -17,7 +17,7 @@ public class LocalTimeCoercing implements Coercing { - private final static DateTimeFormatter dateFormatter = DateTimeFormatter.ISO_LOCAL_TIME; + private static final DateTimeFormatter DATE_FORMATTER = DateTimeFormatter.ISO_LOCAL_TIME; @Override public String serialize(final Object input) throws CoercingSerializeException { @@ -32,7 +32,7 @@ public String serialize(final Object input) throws CoercingSerializeException { ); } try { - return dateFormatter.format(temporalAccessor); + return DATE_FORMATTER.format(temporalAccessor); } catch (DateTimeException e) { throw new CoercingSerializeException( "Unable to turn TemporalAccessor into full time because of : '" + e.getMessage() + "'." @@ -73,7 +73,7 @@ public LocalTime parseLiteral(final Object input) throws CoercingParseLiteralExc private static LocalTime parseTime(String s, Function exceptionMaker) { try { - TemporalAccessor temporalAccessor = dateFormatter.parse(s); + TemporalAccessor temporalAccessor = DATE_FORMATTER.parse(s); return LocalTime.from(temporalAccessor); } catch (DateTimeParseException e) { throw exceptionMaker.apply("Invalid local time value : '" + s + "'. because of : '" + e.getMessage() + "'"); diff --git a/src/main/java/graphql/scalars/datetime/TimeScalar.java b/src/main/java/graphql/scalars/datetime/TimeScalar.java index ea75c93..1ce9ba9 100644 --- a/src/main/java/graphql/scalars/datetime/TimeScalar.java +++ b/src/main/java/graphql/scalars/datetime/TimeScalar.java @@ -22,11 +22,13 @@ * Access this via {@link graphql.scalars.ExtendedScalars#Time} */ @Internal -public class TimeScalar { +public final class TimeScalar { - private final static DateTimeFormatter dateFormatter = DateTimeFormatter.ISO_OFFSET_TIME; + private static final DateTimeFormatter dateFormatter = DateTimeFormatter.ISO_OFFSET_TIME; - public static GraphQLScalarType INSTANCE; + public static final GraphQLScalarType INSTANCE; + + private TimeScalar() {} static { Coercing coercing = new Coercing() { diff --git a/src/main/java/graphql/scalars/java/JavaPrimitives.java b/src/main/java/graphql/scalars/java/JavaPrimitives.java index 75a0ddf..ab401e5 100644 --- a/src/main/java/graphql/scalars/java/JavaPrimitives.java +++ b/src/main/java/graphql/scalars/java/JavaPrimitives.java @@ -19,7 +19,9 @@ * Access these via {@link graphql.scalars.ExtendedScalars} */ @Internal -public class JavaPrimitives { +public final class JavaPrimitives { + + private JavaPrimitives() {} private static final BigInteger LONG_MAX = BigInteger.valueOf(Long.MAX_VALUE); private static final BigInteger LONG_MIN = BigInteger.valueOf(Long.MIN_VALUE); diff --git a/src/main/java/graphql/scalars/locale/LocaleScalar.java b/src/main/java/graphql/scalars/locale/LocaleScalar.java index c1b05aa..78101b4 100644 --- a/src/main/java/graphql/scalars/locale/LocaleScalar.java +++ b/src/main/java/graphql/scalars/locale/LocaleScalar.java @@ -17,9 +17,11 @@ * Access this via {@link graphql.scalars.ExtendedScalars#Locale} */ @Internal -public class LocaleScalar { +public final class LocaleScalar { - public static GraphQLScalarType INSTANCE; + private LocaleScalar() {} + + public static final GraphQLScalarType INSTANCE; static { Coercing coercing = new Coercing() { diff --git a/src/main/java/graphql/scalars/numeric/FloatCoercing.java b/src/main/java/graphql/scalars/numeric/FloatCoercing.java index 8527651..3563b92 100644 --- a/src/main/java/graphql/scalars/numeric/FloatCoercing.java +++ b/src/main/java/graphql/scalars/numeric/FloatCoercing.java @@ -14,7 +14,7 @@ @Internal abstract class FloatCoercing implements Coercing { - abstract protected Double check(Double d, Function exceptionMaker); + protected abstract Double check(Double d, Function exceptionMaker); @Override public Double serialize(Object input) throws CoercingSerializeException { diff --git a/src/main/java/graphql/scalars/numeric/IntCoercing.java b/src/main/java/graphql/scalars/numeric/IntCoercing.java index a430642..d70cce7 100644 --- a/src/main/java/graphql/scalars/numeric/IntCoercing.java +++ b/src/main/java/graphql/scalars/numeric/IntCoercing.java @@ -14,7 +14,7 @@ @Internal abstract class IntCoercing implements Coercing { - abstract protected Integer check(Integer i, Function exceptionMaker); + protected abstract Integer check(Integer i, Function exceptionMaker); @Override public Integer serialize(Object input) throws CoercingSerializeException { diff --git a/src/main/java/graphql/scalars/numeric/NegativeFloatScalar.java b/src/main/java/graphql/scalars/numeric/NegativeFloatScalar.java index 422634b..e979a2d 100644 --- a/src/main/java/graphql/scalars/numeric/NegativeFloatScalar.java +++ b/src/main/java/graphql/scalars/numeric/NegativeFloatScalar.java @@ -9,15 +9,17 @@ * Access this via {@link graphql.scalars.ExtendedScalars#NegativeFloat} */ @Internal -public class NegativeFloatScalar { +public final class NegativeFloatScalar { - public static GraphQLScalarType INSTANCE = GraphQLScalarType.newScalar() + private NegativeFloatScalar() {} + + public static final GraphQLScalarType INSTANCE = GraphQLScalarType.newScalar() .name("NegativeFloat") .description("An Float scalar that must be a negative value") .coercing(new FloatCoercing() { @Override protected Double check(Double d, Function exceptionMaker) { - if (!(d < 0)) { + if (d >= 0.0d) { throw exceptionMaker.apply("The value must be a negative value"); } return d; diff --git a/src/main/java/graphql/scalars/numeric/NegativeIntScalar.java b/src/main/java/graphql/scalars/numeric/NegativeIntScalar.java index d941e68..91f0e39 100644 --- a/src/main/java/graphql/scalars/numeric/NegativeIntScalar.java +++ b/src/main/java/graphql/scalars/numeric/NegativeIntScalar.java @@ -9,15 +9,17 @@ * Access this via {@link graphql.scalars.ExtendedScalars#NegativeInt} */ @Internal -public class NegativeIntScalar { +public final class NegativeIntScalar { - public static GraphQLScalarType INSTANCE = GraphQLScalarType.newScalar() + private NegativeIntScalar() {} + + public static final GraphQLScalarType INSTANCE = GraphQLScalarType.newScalar() .name("NegativeInt") .description("An Int scalar that must be a negative value") .coercing(new IntCoercing() { @Override protected Integer check(Integer i, Function exceptionMaker) { - if (!(i < 0)) { + if (i >= 0) { throw exceptionMaker.apply("The value must be a negative integer"); } return i; diff --git a/src/main/java/graphql/scalars/numeric/NonNegativeFloatScalar.java b/src/main/java/graphql/scalars/numeric/NonNegativeFloatScalar.java index d12e690..2b155c8 100644 --- a/src/main/java/graphql/scalars/numeric/NonNegativeFloatScalar.java +++ b/src/main/java/graphql/scalars/numeric/NonNegativeFloatScalar.java @@ -9,15 +9,17 @@ * Access this via {@link graphql.scalars.ExtendedScalars#NonNegativeFloat} */ @Internal -public class NonNegativeFloatScalar { +public final class NonNegativeFloatScalar { - public static GraphQLScalarType INSTANCE = GraphQLScalarType.newScalar() + private NonNegativeFloatScalar() {} + + public static final GraphQLScalarType INSTANCE = GraphQLScalarType.newScalar() .name("NonNegativeFloat") .description("An Float scalar that must be greater than or equal to zero") .coercing(new FloatCoercing() { @Override protected Double check(Double d, Function exceptionMaker) { - if (!(d >= 0)) { + if (d < 0.0d) { throw exceptionMaker.apply("The value must be greater than or equal to zero"); } return d; diff --git a/src/main/java/graphql/scalars/numeric/NonNegativeIntScalar.java b/src/main/java/graphql/scalars/numeric/NonNegativeIntScalar.java index d9a5791..da268d5 100644 --- a/src/main/java/graphql/scalars/numeric/NonNegativeIntScalar.java +++ b/src/main/java/graphql/scalars/numeric/NonNegativeIntScalar.java @@ -9,15 +9,17 @@ * Access this via {@link graphql.scalars.ExtendedScalars#NonNegativeInt} */ @Internal -public class NonNegativeIntScalar { +public final class NonNegativeIntScalar { - public static GraphQLScalarType INSTANCE = GraphQLScalarType.newScalar() + private NonNegativeIntScalar() {} + + public static final GraphQLScalarType INSTANCE = GraphQLScalarType.newScalar() .name("NonNegativeInt") .description("An Int scalar that must be greater than or equal to zero") .coercing(new IntCoercing() { @Override protected Integer check(Integer i, Function exceptionMaker) { - if (!(i >= 0)) { + if (i < 0) { throw exceptionMaker.apply("The value must be greater than or equal to zero"); } return i; diff --git a/src/main/java/graphql/scalars/numeric/NonPositiveFloatScalar.java b/src/main/java/graphql/scalars/numeric/NonPositiveFloatScalar.java index 80ca3e6..3b901b9 100644 --- a/src/main/java/graphql/scalars/numeric/NonPositiveFloatScalar.java +++ b/src/main/java/graphql/scalars/numeric/NonPositiveFloatScalar.java @@ -9,13 +9,16 @@ * Access this via {@link graphql.scalars.ExtendedScalars#NonPositiveFloat} */ @Internal -public class NonPositiveFloatScalar { - public static GraphQLScalarType INSTANCE = GraphQLScalarType.newScalar() +public final class NonPositiveFloatScalar { + + private NonPositiveFloatScalar() {} + + public static final GraphQLScalarType INSTANCE = GraphQLScalarType.newScalar() .name("NonPositiveFloat").description("An Float scalar that must be less than or equal to zero") .coercing(new FloatCoercing() { @Override protected Double check(Double d, Function exceptionMaker) { - if (!(d <= 0)) { + if (d > 0) { throw exceptionMaker.apply("The value must be less than or equal to zero"); } return d; diff --git a/src/main/java/graphql/scalars/numeric/NonPositiveIntScalar.java b/src/main/java/graphql/scalars/numeric/NonPositiveIntScalar.java index 7be1d7a..cf9b43c 100644 --- a/src/main/java/graphql/scalars/numeric/NonPositiveIntScalar.java +++ b/src/main/java/graphql/scalars/numeric/NonPositiveIntScalar.java @@ -9,14 +9,17 @@ * Access this via {@link graphql.scalars.ExtendedScalars#NonPositiveInt} */ @Internal -public class NonPositiveIntScalar { - public static GraphQLScalarType INSTANCE = GraphQLScalarType.newScalar() +public final class NonPositiveIntScalar { + + private NonPositiveIntScalar() {} + + public static final GraphQLScalarType INSTANCE = GraphQLScalarType.newScalar() .name("NonPositiveInt") .description("An Int scalar that must be less than or equal to zero") .coercing(new IntCoercing() { @Override protected Integer check(Integer i, Function exceptionMaker) { - if (!(i <= 0)) { + if (i > 0) { throw exceptionMaker.apply("The value must be less than or equal to zero"); } return i; diff --git a/src/main/java/graphql/scalars/numeric/PositiveFloatScalar.java b/src/main/java/graphql/scalars/numeric/PositiveFloatScalar.java index 65a3271..ca6cc31 100644 --- a/src/main/java/graphql/scalars/numeric/PositiveFloatScalar.java +++ b/src/main/java/graphql/scalars/numeric/PositiveFloatScalar.java @@ -9,14 +9,17 @@ * Access this via {@link graphql.scalars.ExtendedScalars#PositiveFloat} */ @Internal -public class PositiveFloatScalar { - public static GraphQLScalarType INSTANCE = GraphQLScalarType.newScalar() +public final class PositiveFloatScalar { + + private PositiveFloatScalar() {} + + public static final GraphQLScalarType INSTANCE = GraphQLScalarType.newScalar() .name("PositiveFloat") .description("An Float scalar that must be a positive value") .coercing(new FloatCoercing() { @Override protected Double check(Double d, Function exceptionMaker) { - if (!(d > 0)) { + if (d <= 0) { throw exceptionMaker.apply("The value must be a positive value"); } return d; diff --git a/src/main/java/graphql/scalars/numeric/PositiveIntScalar.java b/src/main/java/graphql/scalars/numeric/PositiveIntScalar.java index 0af5b96..80f5613 100644 --- a/src/main/java/graphql/scalars/numeric/PositiveIntScalar.java +++ b/src/main/java/graphql/scalars/numeric/PositiveIntScalar.java @@ -9,15 +9,17 @@ * Access this via {@link graphql.scalars.ExtendedScalars#PositiveInt} */ @Internal -public class PositiveIntScalar { +public final class PositiveIntScalar { - public static GraphQLScalarType INSTANCE = GraphQLScalarType.newScalar() + private PositiveIntScalar() {} + + public static final GraphQLScalarType INSTANCE = GraphQLScalarType.newScalar() .name("PositiveInt") .description("An Int scalar that must be a positive value") .coercing(new IntCoercing() { @Override protected Integer check(Integer i, Function exceptionMaker) { - if (!(i > 0)) { + if (i <= 0) { throw exceptionMaker.apply("The value must be a positive integer"); } return i; diff --git a/src/main/java/graphql/scalars/object/JsonScalar.java b/src/main/java/graphql/scalars/object/JsonScalar.java index c3e2d79..ee1e2e4 100644 --- a/src/main/java/graphql/scalars/object/JsonScalar.java +++ b/src/main/java/graphql/scalars/object/JsonScalar.java @@ -11,9 +11,11 @@ * Access this via {@link graphql.scalars.ExtendedScalars#Json} */ @Internal -public class JsonScalar { +public final class JsonScalar { - public static GraphQLScalarType INSTANCE = GraphQLScalarType.newScalar() + private JsonScalar() {} + + public static final GraphQLScalarType INSTANCE = GraphQLScalarType.newScalar() .name("JSON") .description("A JSON scalar") .coercing(OBJECT_COERCING) diff --git a/src/main/java/graphql/scalars/object/ObjectScalar.java b/src/main/java/graphql/scalars/object/ObjectScalar.java index 446d9ad..030972b 100644 --- a/src/main/java/graphql/scalars/object/ObjectScalar.java +++ b/src/main/java/graphql/scalars/object/ObjectScalar.java @@ -36,9 +36,11 @@ * Access this via {@link graphql.scalars.ExtendedScalars#Object} */ @Internal -public class ObjectScalar { +public final class ObjectScalar { - static Coercing OBJECT_COERCING = new Coercing() { + private ObjectScalar() {} + + static final Coercing OBJECT_COERCING = new Coercing() { @Override public Object serialize(Object input) throws CoercingSerializeException { return input; diff --git a/src/main/java/graphql/scalars/regex/RegexScalar.java b/src/main/java/graphql/scalars/regex/RegexScalar.java index 746a48e..79a8957 100644 --- a/src/main/java/graphql/scalars/regex/RegexScalar.java +++ b/src/main/java/graphql/scalars/regex/RegexScalar.java @@ -24,7 +24,9 @@ * a regular expression. */ @PublicApi -public class RegexScalar { +public final class RegexScalar { + + private RegexScalar() {} /** * A builder for {@link graphql.scalars.regex.RegexScalar} diff --git a/src/main/java/graphql/scalars/url/UrlScalar.java b/src/main/java/graphql/scalars/url/UrlScalar.java index 2caf4f0..75dceb9 100644 --- a/src/main/java/graphql/scalars/url/UrlScalar.java +++ b/src/main/java/graphql/scalars/url/UrlScalar.java @@ -19,9 +19,11 @@ import static graphql.scalars.util.Kit.typeName; @Internal -public class UrlScalar { +public final class UrlScalar { - public static GraphQLScalarType INSTANCE; + private UrlScalar() {} + + public static final GraphQLScalarType INSTANCE; static { Coercing coercing = new Coercing() {