public final class ModelBuilder extends Object
Modifier and Type | Class and Description |
---|---|
private class |
ModelBuilder.ExecutableElementInfo
Executable elements (methods) along with their declared mirror types etc.
|
private class |
ModelBuilder.StatusHolder
Contains various data that streams need to manipulate and this needs to be accessed by reference.
|
Modifier and Type | Field and Description |
---|---|
private static String |
comparableClass |
private static String |
compareToOverloadName |
private Configuration |
configuration |
private Elements |
elements |
private DiagnosticMessageConsumer |
errorConsumer |
private static String |
externalizableClass |
private static Logger |
LOGGER |
private TypeElement |
masterInterfaceElement |
private NoType |
noType |
private ResourceLoader |
resourceLoader |
private static String |
serializbleClass |
private static HashMap<String,Predicate4<Configuration,Clazz,List<Method>,List<Member>>> |
templateMethodConditions
Controls when corresponding available ST template methods should be called.
|
private STTemplates |
templates |
private TypeBuilder |
typeBuilder |
private Types |
types |
Constructor and Description |
---|
ModelBuilder(Types types,
Elements elements,
DiagnosticMessageConsumer errorConsumer,
TypeElement masterInterfaceElement,
Configuration configuration,
ResourceLoader resourceLoader,
STTemplates templates)
Create an instance of this builder that can build the specified class and all dependencies.
|
Modifier and Type | Method and Description |
---|---|
Clazz |
buildNewCLazz()
Create a Clazz model instance representing a class to be generated along with all its dependent model instances by inspecting
javax.lang.model metadata and the configuration provided by annotation(s) read by annotation processor.
|
private void |
claimAndVerifyMethods(List<Method> nonPropertyMethods,
List<Property> propertyMethods,
Set<String> applicableTemplateImplementedMethodNames) |
private List<Annotation> |
createConstructorAnnotations(Clazz clazz,
List<Parameter> parameters,
boolean primaryConstructor,
boolean includeFactoryMethod) |
private EnumSet<Modifier> |
createConstructorModifiers(EnumSet<Modifier> classModifiers,
List<Parameter> parameters,
boolean includeFactoryMethod,
boolean mustHaveDefaultPublicCtr) |
private List<Annotation> |
createConstructorParameterAnnotations(Clazz clazz,
boolean primaryConstructor,
String parameterName,
boolean includeFactoryMethod) |
private List<Method> |
createConstructorsAndFactoryMethods(Clazz clazz,
ObjectType baseClazzType,
List<Member> members,
EnumSet<Modifier> classModifiers,
String[] baseClazzConstructors) |
private List<List<Parameter>> |
createConstuctorsParameterLists(Clazz clazz,
List<Member> members,
boolean primary,
boolean includeFactoryMethod) |
private List<Annotation> |
createFactoryMethodAnnotations(Clazz clazz,
List<Parameter> parameters,
boolean primaryFactoryMethod) |
private List<Annotation> |
createFactoryMethodParameterAnnotations(Clazz clazz,
boolean primaryFactoryMethod,
String parameterName) |
private List<List<Parameter>> |
createFactoryMethodsParameterLists(Clazz clazz,
List<Member> members,
boolean primary) |
private List<Type> |
createImportTypes(BasicClazz clazz,
DeclaredType baseClazzDeclaredType,
List<DeclaredType> implementedDecalredInterfaceTypes) |
private List<Method> |
createMagicSerializationMethods(BasicClazz clazz) |
private List<Annotation> |
createMemberAnnotations(BasicClazz clazz,
String memberName) |
private Method |
createMethod(BasicClazz clazz,
Map<String,Member> membersByName,
ModelBuilder.StatusHolder statusHolder,
ExecutableElement m,
ExecutableElement mOverriddenBy,
DeclaredType interfaceOrClassMirrorType) |
private List<Annotation> |
createMethodAnnotations(BasicClazz clazz,
String methodName,
List<Parameter> parameters,
EnumSet<Modifier> modifiers) |
private Member |
createPropertyMemberIfValidProperty(BasicClazz clazz,
DeclaredType interfaceOrClassMirrorType,
TypeMirror returnTypeMirror,
List<? extends VariableElement> setterParams,
List<? extends TypeMirror> setterParamTypes,
ExecutableElement methodElement,
PropertyKind kind) |
private String |
createQualifiedClassName(String qualifedInterfaceName,
String sourcePackageName) |
private Property |
createValidatedProperty(BasicClazz clazz,
ModelBuilder.StatusHolder statusHolder,
Type declaringType,
ExecutableElement m,
Type returnType,
List<Parameter> parameters,
List<Type> thrownTypes,
String javaDoc,
PropertyKind propertyKind,
Member propertyMember,
EnumSet<Modifier> modifiers,
ImplementationInfo implementationInfo) |
private List<Type> |
filterImportTypes(BasicClazz clazz,
List<Type> importTypes) |
private List<Member> |
getSelectedComparableMembers(Map<String,Member> membersByName,
Map<String,Member> baseMembersByName,
Method comparableMethodToImplement) |
private static boolean |
instanceImplementationExists(Clazz clazz,
String methodName,
List<Method> methods) |
private static boolean |
mustImplementComparable(Clazz clazz,
List<Method> methods) |
private String |
syntesisePropertyMemberName(String[] propertyPrefixes,
ExecutableElement method) |
private Stream<ModelBuilder.ExecutableElementInfo> |
toExecutableElementAndDeclaredTypePair(DeclaredType interfaceOrClasMirrorType,
Stream<ExecutableElement> elements) |
private static final Logger LOGGER
private static final String comparableClass
private static final String serializbleClass
private static final String externalizableClass
private static final String compareToOverloadName
private static final HashMap<String,Predicate4<Configuration,Clazz,List<Method>,List<Member>>> templateMethodConditions
private final TypeBuilder typeBuilder
private final Types types
private final Elements elements
private final DiagnosticMessageConsumer errorConsumer
private final TypeElement masterInterfaceElement
private final Configuration configuration
private final ResourceLoader resourceLoader
private final STTemplates templates
private final NoType noType
public ModelBuilder(Types types, Elements elements, DiagnosticMessageConsumer errorConsumer, TypeElement masterInterfaceElement, Configuration configuration, ResourceLoader resourceLoader, STTemplates templates)
types
- Types helper from javax.lang.modelelements
- Elements helper from jacax.lang.modelerrorConsumer
- Where to send errors.masterInterfaceElement
- The interface that has been selected for code generation (by an annotation).configuration
- Descripes the user-selected details about what should be generated (combination of annotation(s) and annotation processor setup).resourceLoader
- What to call to get resource filestemplates
- StringTemplate templates holder used to reflect on what methods are supplied.public Clazz buildNewCLazz() throws Exception
Exception
- if a fatal error has occured.private void claimAndVerifyMethods(List<Method> nonPropertyMethods, List<Property> propertyMethods, Set<String> applicableTemplateImplementedMethodNames)
private List<Method> createConstructorsAndFactoryMethods(Clazz clazz, ObjectType baseClazzType, List<Member> members, EnumSet<Modifier> classModifiers, String[] baseClazzConstructors)
private EnumSet<Modifier> createConstructorModifiers(EnumSet<Modifier> classModifiers, List<Parameter> parameters, boolean includeFactoryMethod, boolean mustHaveDefaultPublicCtr)
private List<List<Parameter>> createConstuctorsParameterLists(Clazz clazz, List<Member> members, boolean primary, boolean includeFactoryMethod)
private List<List<Parameter>> createFactoryMethodsParameterLists(Clazz clazz, List<Member> members, boolean primary)
private List<Annotation> createConstructorAnnotations(Clazz clazz, List<Parameter> parameters, boolean primaryConstructor, boolean includeFactoryMethod)
private List<Annotation> createFactoryMethodAnnotations(Clazz clazz, List<Parameter> parameters, boolean primaryFactoryMethod)
private List<Annotation> createConstructorParameterAnnotations(Clazz clazz, boolean primaryConstructor, String parameterName, boolean includeFactoryMethod)
private List<Annotation> createFactoryMethodParameterAnnotations(Clazz clazz, boolean primaryFactoryMethod, String parameterName)
private List<Method> createMagicSerializationMethods(BasicClazz clazz)
private List<Member> getSelectedComparableMembers(Map<String,Member> membersByName, Map<String,Member> baseMembersByName, Method comparableMethodToImplement)
private Stream<ModelBuilder.ExecutableElementInfo> toExecutableElementAndDeclaredTypePair(DeclaredType interfaceOrClasMirrorType, Stream<ExecutableElement> elements)
private Method createMethod(BasicClazz clazz, Map<String,Member> membersByName, ModelBuilder.StatusHolder statusHolder, ExecutableElement m, ExecutableElement mOverriddenBy, DeclaredType interfaceOrClassMirrorType)
private List<Annotation> createMethodAnnotations(BasicClazz clazz, String methodName, List<Parameter> parameters, EnumSet<Modifier> modifiers)
private List<Type> createImportTypes(BasicClazz clazz, DeclaredType baseClazzDeclaredType, List<DeclaredType> implementedDecalredInterfaceTypes)
private Property createValidatedProperty(BasicClazz clazz, ModelBuilder.StatusHolder statusHolder, Type declaringType, ExecutableElement m, Type returnType, List<Parameter> parameters, List<Type> thrownTypes, String javaDoc, PropertyKind propertyKind, Member propertyMember, EnumSet<Modifier> modifiers, ImplementationInfo implementationInfo)
private List<Type> filterImportTypes(BasicClazz clazz, List<Type> importTypes)
private String createQualifiedClassName(String qualifedInterfaceName, String sourcePackageName)
private Member createPropertyMemberIfValidProperty(BasicClazz clazz, DeclaredType interfaceOrClassMirrorType, TypeMirror returnTypeMirror, List<? extends VariableElement> setterParams, List<? extends TypeMirror> setterParamTypes, ExecutableElement methodElement, PropertyKind kind)
private List<Annotation> createMemberAnnotations(BasicClazz clazz, String memberName)
private String syntesisePropertyMemberName(String[] propertyPrefixes, ExecutableElement method)
private static boolean mustImplementComparable(Clazz clazz, List<Method> methods)
Version 2.0.0 generated on 2014-11-22 at 09:45 - (C) 41concepts Aps. Refer to project homepage valjogen.41concepts.com for more information.