4040
4141/**
4242 * Provides Registry to resolve GraphQL Query Java Scalar Types
43- *
43+ *
4444 * @author Igor Dianov
4545 *
4646 */
4747public class JavaScalars {
48+
4849 static final Logger log = LoggerFactory .getLogger (JavaScalars .class );
4950
5051 private static HashMap <Class <?>, GraphQLScalarType > scalarsRegistry = new HashMap <Class <?>, GraphQLScalarType >();
51-
52+
5253 static {
5354 scalarsRegistry .put (String .class , Scalars .GraphQLString );
5455
@@ -66,33 +67,39 @@ public class JavaScalars {
6667
6768 scalarsRegistry .put (Long .class , Scalars .GraphQLLong );
6869 scalarsRegistry .put (long .class , Scalars .GraphQLLong );
69-
70+
7071 scalarsRegistry .put (Boolean .class , Scalars .GraphQLBoolean );
7172 scalarsRegistry .put (boolean .class , Scalars .GraphQLBoolean );
7273
74+ scalarsRegistry .put (BigInteger .class , Scalars .GraphQLBigInteger );
75+
76+ scalarsRegistry .put (char .class , Scalars .GraphQLChar );
77+ scalarsRegistry .put (Character .class , Scalars .GraphQLChar );
78+
7379 scalarsRegistry .put (BigDecimal .class , Scalars .GraphQLBigDecimal );
74-
80+
7581 scalarsRegistry .put (LocalDateTime .class , new GraphQLScalarType ("LocalDateTime" , "LocalDateTime type" , new GraphQLLocalDateTimeCoercing ()));
7682 scalarsRegistry .put (LocalDate .class , new GraphQLScalarType ("LocalDate" , "LocalDate type" , new GraphQLLocalDateCoercing ()));
7783 scalarsRegistry .put (Date .class , new GraphQLScalarType ("Date" , "Date type" , new GraphQLDateCoercing ()));
7884 scalarsRegistry .put (UUID .class , new GraphQLScalarType ("UUID" , "UUID type" , new GraphQLUUIDCoercing ()));
7985 scalarsRegistry .put (Object .class , new GraphQLScalarType ("Object" , "Object type" , new GraphQLObjectCoercing ()));
8086 }
81-
87+
8288 public static GraphQLScalarType of (Class <?> key ) {
8389 return scalarsRegistry .get (key );
8490 }
8591
8692 public JavaScalars register (Class <?> key , GraphQLScalarType value ) {
8793 Assert .assertNotNull (key , "key parameter cannot be null." );
8894 Assert .assertNotNull (value , "value parameter cannot be null." );
89-
95+
9096 scalarsRegistry .put (key , value );
91-
97+
9298 return this ;
9399 }
94-
100+
95101 public static class GraphQLLocalDateTimeCoercing implements Coercing <Object , Object > {
102+
96103 @ Override
97104 public Object serialize (Object input ) {
98105 if (input instanceof String ) {
@@ -136,8 +143,9 @@ private LocalDateTime parseStringToLocalDateTime(String input) {
136143 }
137144 }
138145 };
139-
146+
140147 public static class GraphQLLocalDateCoercing implements Coercing <Object , Object > {
148+
141149 @ Override
142150 public Object serialize (Object input ) {
143151 if (input instanceof String ) {
@@ -229,14 +237,14 @@ public static class GraphQLUUIDCoercing implements Coercing<Object, Object> {
229237 @ Override
230238 public Object serialize (Object input ) {
231239 if (input instanceof UUID ) {
232- return input ;
240+ return input ;
233241 }
234242 return null ;
235243 }
236244
237245 @ Override
238246 public Object parseValue (Object input ) {
239- if (input instanceof String ) {
247+ if (input instanceof String ) {
240248 return parseStringToUUID ((String ) input );
241249 }
242250 return null ;
@@ -277,5 +285,5 @@ public Object parseLiteral(Object input) {
277285 return input ;
278286 }
279287 };
280-
288+
281289}
0 commit comments