Class AbstractType
java.lang.Object
com.graphql_java_generator.plugin.language.impl.AbstractType
- All Implemented Interfaces:
Type
- Direct Known Subclasses:
EnumType
,ObjectType
,ScalarType
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.graphql_java_generator.plugin.language.Type
Type.GraphQlType, Type.TargetFileType
-
Constructor Summary
ConstructorDescriptionAbstractType
(String name, Type.GraphQlType graphQlType, CommonConfiguration configuration, DocumentParser documentParser) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addAnnotation
(String annotationToAdd) The annotation setter should be added.void
addAnnotation
(String annotationToAdd, boolean replace) The annotation setter should be added.void
Add the given class as an import for the current type.void
addImportForUtilityClasses
(String targetPackageName, String classname) Same as#addImport(String, String, String)
, but for the utility classesReturns the annotation or annotations that must be added to this type.Returns the camel case String, based on the object's name.The java class simple name for this type.The GraphQlType for this typeThe name of the field, as it can be used in the Java code.protected String
protected String
void
setAnnotation
(String annotation) Deprecated.void
setComments
(List<graphql.language.Comment> comments) toString()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface com.graphql_java_generator.plugin.language.Type
getAppliedDirectives, getClassFullName, getComments, getDataFetcher, getDescription, getField, getFields, getIdentifier, getImports, getImportsForUtilityClasses, getName, getPackageName, getRequestType, getTargetFileName, isCustomScalar, isEnum, isInputType, isScalar
-
Constructor Details
-
AbstractType
public AbstractType(String name, Type.GraphQlType graphQlType, CommonConfiguration configuration, DocumentParser documentParser) - Parameters:
name
-graphQlType
- The type of objectconfiguration
- The current plugin configuration, which is accessible through an interface that extendsCommonConfiguration
documentParser
- TheDocumentParser
that has parsed the schema, and so that contains the whole schema definition
-
-
Method Details
-
getGraphQlType
Description copied from interface:Type
The GraphQlType for this type- Specified by:
getGraphQlType
in interfaceType
- Returns:
-
getClassSimpleName
The java class simple name for this type. It may be and interface or a concrete class.- Specified by:
getClassSimpleName
in interfaceType
- Returns:
- The java classname is usually the name of the type. But in some case, collision my occur with the Java syntax. In this cas, this method will return a classname different from the name
-
getJavaName
Description copied from interface:Type
The name of the field, as it can be used in the Java code. If the name is a java keyword (class, default, break...), the java name it prefixed by an underscore.
If a prefix or a suffix has been defined in the plugin configuration for this kind of item (object type, union, enum...), then the java name contains the prefix and/or the suffix- Specified by:
getJavaName
in interfaceType
- Returns:
- The name of the type, as it can be used in Java code
-
getPrefix
-
getSuffix
-
getCamelCaseName
Returns the camel case String, based on the object's name. For instance: bigFoot for a type named BigFoot- Specified by:
getCamelCaseName
in interfaceType
- Returns:
-
toString
-
getAnnotation
Description copied from interface:Type
Returns the annotation or annotations that must be added to this type.- Specified by:
getAnnotation
in interfaceType
- Returns:
- The relevant annotation(s) ready to add directly as-is in the Velocity template, or "" (an empty string) if there is no annotation to add. The return is never null.
-
setAnnotation
Deprecated.The annotation setter should be used. Please use theaddAnnotation(String)
instead- Parameters:
annotation
- The annotation, that will replace the current one
-
addImport
Description copied from interface:Type
Add the given class as an import for the current type. This import will be added only if the given class is not in the same package as the java class for this type, and if it doesn't already exist in the imports set.
classes from the java.lang package are not imported.
Note1: for inner class, the classname may be "MainClassname$InnerClassname" (as returned by theClass.getName()
method), par as "MainClassname.InnerClassname".
Note2: it is not allowed to import a class of the same name as the current class: there would be a name conflict. In this case, the import "silently fails": the class is not imported in the imports list. -
addImportForUtilityClasses
Description copied from interface:Type
Same as#addImport(String, String, String)
, but for the utility classes- Specified by:
addImportForUtilityClasses
in interfaceType
- Parameters:
targetPackageName
- The package where the objects are generatedclassname
- The full class name (java.lang.String for instance) of the class to import
-
addAnnotation
The annotation setter should be added. This method allows to properly manage indentation in the generated source code- Specified by:
addAnnotation
in interfaceType
- Parameters:
annotationToAdd
- The annotation, that will be added to the current one
-
addAnnotation
The annotation setter should be added. This method allows to properly manage indentation in the generated source code- Specified by:
addAnnotation
in interfaceType
- Parameters:
annotationToAdd
- The annotation, that will be added to the current one
-
setComments
-