1515 */
1616class GraphqlTypeToJavaTypeMapper {
1717
18+ /**
19+ * Map GraphQL's FieldDefinition to a Freemarker-understandable format of operation
20+ *
21+ * @param mappingConfig Global mapping configuration
22+ * @param fieldDef GraphQL field definition
23+ * @param parentTypeName Name of the parent type
24+ * @return Freemarker-understandable format of parameter (field)
25+ */
1826 public static ParameterDefinition map (MappingConfig mappingConfig , FieldDefinition fieldDef , String parentTypeName ) {
1927 ParameterDefinition parameter = new ParameterDefinition ();
2028 parameter .setName (MapperUtils .capitalizeIfRestricted (fieldDef .getName ()));
@@ -23,6 +31,14 @@ public static ParameterDefinition map(MappingConfig mappingConfig, FieldDefiniti
2331 return parameter ;
2432 }
2533
34+ /**
35+ * Map GraphQL's InputValueDefinition to a Freemarker-understandable format of operation
36+ *
37+ * @param mappingConfig Global mapping configuration
38+ * @param inputValueDefinition GraphQL input value definition
39+ * @param parentTypeName Name of the parent type
40+ * @return Freemarker-understandable format of parameter (field)
41+ */
2642 public static ParameterDefinition map (MappingConfig mappingConfig , InputValueDefinition inputValueDefinition , String parentTypeName ) {
2743 ParameterDefinition parameter = new ParameterDefinition ();
2844 parameter .setName (MapperUtils .capitalizeIfRestricted (inputValueDefinition .getName ()));
@@ -31,22 +47,47 @@ public static ParameterDefinition map(MappingConfig mappingConfig, InputValueDef
3147 return parameter ;
3248 }
3349
50+ /**
51+ * Convert GraphQL type to a corresponding Java type
52+ *
53+ * @param mappingConfig Global mapping configuration
54+ * @param type GraphQL type
55+ * @return Corresponding Java type
56+ */
3457 static String getJavaType (MappingConfig mappingConfig , Type type ) {
3558 return getJavaType (mappingConfig , type , null , null );
3659 }
3760
38- static String getJavaType (MappingConfig mappingConfig , Type type , String name , String parentTypeName ) {
39- if (type instanceof TypeName ) {
40- return getJavaType (mappingConfig , ((TypeName ) type ).getName (), name , parentTypeName );
41- } else if (type instanceof ListType ) {
42- String mappedCollectionType = getJavaType (mappingConfig , ((ListType ) type ).getType (), name , parentTypeName );
61+ /**
62+ * Convert GraphQL type to a corresponding Java type
63+ *
64+ * @param mappingConfig Global mapping configuration
65+ * @param graphlType GraphQL type
66+ * @param name GraphQL type name
67+ * @param parentTypeName Name of the parent type
68+ * @return Corresponding Java type
69+ */
70+ static String getJavaType (MappingConfig mappingConfig , Type graphlType , String name , String parentTypeName ) {
71+ if (graphlType instanceof TypeName ) {
72+ return getJavaType (mappingConfig , ((TypeName ) graphlType ).getName (), name , parentTypeName );
73+ } else if (graphlType instanceof ListType ) {
74+ String mappedCollectionType = getJavaType (mappingConfig , ((ListType ) graphlType ).getType (), name , parentTypeName );
4375 return wrapIntoJavaCollection (mappedCollectionType );
44- } else if (type instanceof NonNullType ) {
45- return getJavaType (mappingConfig , ((NonNullType ) type ).getType (), name , parentTypeName );
76+ } else if (graphlType instanceof NonNullType ) {
77+ return getJavaType (mappingConfig , ((NonNullType ) graphlType ).getType (), name , parentTypeName );
4678 }
4779 return null ;
4880 }
4981
82+ /**
83+ * Convert GraphQL type to a corresponding Java type
84+ *
85+ * @param mappingConfig Global mapping configuration
86+ * @param graphlType GraphQL type
87+ * @param name GraphQL type name
88+ * @param parentTypeName Name of the parent type
89+ * @return Corresponding Java type
90+ */
5091 private static String getJavaType (MappingConfig mappingConfig , String graphlType , String name , String parentTypeName ) {
5192 Map <String , String > customTypesMapping = mappingConfig .getCustomTypesMapping ();
5293 if (name != null && parentTypeName != null && customTypesMapping .containsKey (parentTypeName + "." + name )) {
@@ -69,8 +110,17 @@ private static String getJavaType(MappingConfig mappingConfig, String graphlType
69110 }
70111 }
71112
72- static List <String > getAnnotations (MappingConfig mappingConfig , Type type , String name , String parentTypeName ) {
73- return getAnnotations (mappingConfig , type , name , parentTypeName , false );
113+ /**
114+ * Get annotations for a given GraphQL type
115+ *
116+ * @param mappingConfig Global mapping configuration
117+ * @param graphlType GraphQL type
118+ * @param name GraphQL type name
119+ * @param parentTypeName Name of the parent type
120+ * @return list of Java annotations for a given GraphQL type
121+ */
122+ static List <String > getAnnotations (MappingConfig mappingConfig , Type graphlType , String name , String parentTypeName ) {
123+ return getAnnotations (mappingConfig , graphlType , name , parentTypeName , false );
74124 }
75125
76126 private static List <String > getAnnotations (MappingConfig mappingConfig , Type type , String name , String parentTypeName ,
0 commit comments