Class ConfigurationClassNameGenerator
java.lang.Object
me.bristermitten.mittenlib.annotations.compile.ConfigurationClassNameGenerator
Responsible for generating proper class names for configuration classes. This class handles the
conversion between DTO class names and their corresponding implementation class names, taking
into account nesting, package names, and custom naming specified in annotations.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncom.palantir.javapoet.ClassNamegenerateConfigurationClassName(TypeElement configDTOType) Generates a ClassName for the actual generated configuration class from a given DTO, using the package of the givenTypeElement.com.palantir.javapoet.ClassNameGet the concrete class name for a config structure.com.palantir.javapoet.TypeNamegetConfigPropertyClassName(TypeMirror mirror) Get the config property class name for a type mirror.com.palantir.javapoet.ClassNamecom.palantir.javapoet.ClassNameGets the ClassName of the loader for a given TypeMirror.com.palantir.javapoet.ClassNameGets the ClassName of the deserializer for a given configuration structure.Gets the field name for a deserializer field based on the public config type.@Nullable com.palantir.javapoet.ClassNamecom.palantir.javapoet.ClassNamegetLoaderModuleClassName(String packageName) getProvidesMethodName(String simpleName) getProvidesProviderMethodName(String simpleName) getProvidesToConfigSetMethodName(String simpleName) getProvidesToProviderSetMethodName(String simpleName) com.palantir.javapoet.ClassNameGet the public class name for a config structure.com.palantir.javapoet.ClassNameGets theClassNameof the serializer for a given configuration structure.Gets the field name for a serializer instance based on the public config type.com.palantir.javapoet.ClassNamegetValidatorElementErrorFieldName(Property property) getValidatorElementFieldName(Property property) getValidatorErrorFieldName(Property property) getValidatorFieldName(Property property) getValidatorKeyErrorFieldName(Property property) getValidatorKeyFieldName(Property property) com.palantir.javapoet.TypeNamepublicPropertyClassName(TypeMirror mirror) Get the public property class name for a type mirror.com.palantir.javapoet.TypeNameGet the public property class name for a property.static com.palantir.javapoet.ClassNametranslateConfigClassName(com.palantir.javapoet.ClassName dtoClassName) Creates a class name for the implementation of a DTO class.com.palantir.javapoet.ClassNameCreates a class name for the implementation of a configuration structure.
-
Field Details
-
DESERIALIZER_SUFFIX
- See Also:
-
SERIALIZER_SUFFIX
- See Also:
-
VALIDATOR_SUFFIX
- See Also:
-
PROVIDER_SUFFIX
- See Also:
-
DEFAULT_METHOD_ACCESS_SUFFIX
- See Also:
-
CONFIG_LOADER_MODULE_NAME
- See Also:
-
-
Constructor Details
-
ConfigurationClassNameGenerator
-
-
Method Details
-
translateConfigClassName
public static com.palantir.javapoet.ClassName translateConfigClassName(com.palantir.javapoet.ClassName dtoClassName) Creates a class name for the implementation of a DTO class. If the class name ends with "DTO", it removes that suffix. Otherwise, it appends "Impl" to the class name.- Parameters:
dtoClassName- The original DTO class name- Returns:
- The implementation class name
-
translateConfigClassName
Creates a class name for the implementation of a configuration structure. This method handles nested classes by checking if the structure is enclosed in another structure.- Parameters:
ast- The abstract configuration structure- Returns:
- The implementation class name, properly nested if necessary
-
getPublicClassName
Get the public class name for a config structure. "Public" is defined as the type that the user should primarily interact with. For interfaces, this is the interface itself, and for classes, this is the generated implementation class (as the DTO class becomes mostly useless after code generation).- Parameters:
ast- The abstract configuration structure- Returns:
- The public class name that should be used for interaction with this configuration
-
getConcreteConfigClassName
Get the concrete class name for a config structure. This is the actual implementation class that will be instantiated. For classes, this is the original DTO class, and for interfaces, this is the generated implementation class.- Parameters:
ast- The abstract configuration structure- Returns:
- The concrete class name that will be instantiated
-
getConfigPropertyClassName
Get the config property class name for a type mirror.- Parameters:
mirror- The type mirror- Returns:
- The config property class name
-
publicPropertyClassName
Get the public property class name for a property.- Parameters:
p- The property- Returns:
- The public property class name
-
publicPropertyClassName
Get the public property class name for a type mirror.- Parameters:
mirror- The type mirror- Returns:
- The public property class name
-
generateConfigurationClassName
Generates a ClassName for the actual generated configuration class from a given DTO, using the package of the givenTypeElement. If the given type is not a config, its unchanged name is returned. The returned class name will be the same as the given type, but with the suffix removed. It can also be manually specified in the Config annotation withConfig.className()- Parameters:
configDTOType- The DTO type- Returns:
- The generated ClassName
-
getDeserializerProviderFieldName
-
getSerializerProviderFieldName
-
getValidatorFieldName
-
getValidatorElementFieldName
-
getValidatorKeyFieldName
-
getValidatorErrorFieldName
-
getValidatorElementErrorFieldName
-
getValidatorKeyErrorFieldName
-
getDefaultMethodAccessClassName
-
getLoaderModuleClassName
-
getProvidesProviderMethodName
-
getProvidesMethodName
-
getProvidesToConfigSetMethodName
-
getProvidesToProviderSetMethodName
-
getDeserializerClassName
Gets the ClassName of the deserializer for a given configuration structure. ForMyConfig, the deserializer isMyConfigImpl. For nested class OuterConfig.InnerConfig, the loader is OuterConfigDeserializer.InnerConfigDeserializer. -
getDeserializerClassName
Gets the ClassName of the loader for a given TypeMirror. -
getDeserializerFieldName
Gets the field name for a deserializer field based on the public config type. E.g., forInterfaceConfig, it returnsinterfaceConfigDeserializer. -
getSerializerClassName
Gets theClassNameof the serializer for a given configuration structure. ForMyConfigImpl, the saver isMyConfigImplSerializer. For nested classOuterConfigImpl.InnerConfigImpl, the saver isOuterConfigImplSerializer.InnerConfigImplSerializer. -
getSerializerFieldName
Gets the field name for a serializer instance based on the public config type. E.g., forInterfaceConfig, it returns"interfaceConfigSerializer". -
getValidatorClassName
-
getInnerDaoName
-