Package org.derive4j.processor
Class DeriveUtilsImpl
java.lang.Object
org.derive4j.processor.DeriveUtilsImpl
- All Implemented Interfaces:
DeriveUtils
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final DeriveConfigBuilder
private final Function
<Flavour, Optional<EitherModel>> private final Elements
private final Function
<Flavour, SamInterface> private final Function
<Flavour, SamInterface> private final ObjectModel
private final Function
<Flavour, OptionModel> private final Types
-
Constructor Summary
ConstructorsConstructorDescriptionDeriveUtilsImpl
(Elements Elements, Types Types, DeriveConfigBuilder deriveConfigBuilder) -
Method Summary
Modifier and TypeMethodDescriptionprivate boolean
allAbstractMethods
(TypeElement typeElement) allAbstractMethods
(DeclaredType declaredType) allStaticFields
(TypeElement typeElement) allStaticMethods
(TypeElement typeElement) asDeclaredType
(TypeMirror typeMirror) private com.squareup.javapoet.CodeBlock
asTypeArguments
(Stream<? extends TypeMirror> typeVariables) asTypeElement
(TypeMirror typeMirror) capitalize
(CharSequence string) private Optional
<EitherModel> eitherModel
(String eitherClassQualifiedName, String leftConstructor, String rightConstructor) eitherModel
(Flavour flavour) elements()
private Optional
<InstanceLocation> findCompiledInstance
(TypeElement typeElementContext, TypeElement typeClass, TypeElement typeElement, DeclaredType declaredType, List<TypeElement> lowPriorityProviders, Optional<com.squareup.javapoet.ClassName> deriveTarget, Optional<com.squareup.javapoet.ClassName> deriveTargetExtend, Optional<com.squareup.javapoet.ClassName> contextExtend) private Function
<TypeElement, Stream<InstanceLocation>> findCompiledInstanceIn
(TypeElement typeElement, DeclaredType declaredType, Optional<com.squareup.javapoet.ClassName> deriveTarget, TypeMirror rawTypeClass) private Optional
<DeclaredType> findFirstDeclaredTypeOf
(TypeElement typeElement, TypeMirror inType) findInstance
(TypeElement typeElementContext, com.squareup.javapoet.ClassName typeClassContext, com.squareup.javapoet.ClassName typeClass, TypeElement typeElement, DeclaredType declaredType, List<TypeElement> lowPriorityProviders) findTypeElement
(com.squareup.javapoet.ClassName cn) function0Model
(Flavour flavour) function1Model
(Flavour flavour) private String
generatedInstanceMethodName
(TypeElement typeClass, TypeElement typeElement) generateInstance
(AlgebraicDataType adt, com.squareup.javapoet.ClassName typeClass, List<TypeElement> lowPriorityProviders, Function<InstanceUtils, DerivedCodeSpec> generateInstance) private static Stream
<TypeElement> instanceInitializer
(TypeElement typeElementContext, com.squareup.javapoet.ClassName typeClassContext, com.squareup.javapoet.ClassName typeClass, TypeMirror type, List<TypeElement> lowPriorityProviders) private String
instanceVariableName
(TypeElement typeClass, TypeMirror type) private Boolean
isNotIn
(List<FreeVariable> previousVars, FreeVariable var) boolean
isWildcarded
(TypeMirror typeMirror) private BoundExpression
join
(BinaryOperator<Expression> expressionJoiner, BoundExpression b1, BoundExpression b2) private static Expression
joinAsArgs
(Expression e1, Expression e2) com.squareup.javapoet.CodeBlock
lambdaImpl
(DataConstructor constructor, com.squareup.javapoet.CodeBlock impl) com.squareup.javapoet.CodeBlock
lambdaImpl
(DataConstructor constructor, String suffix, com.squareup.javapoet.CodeBlock impl) private OptionModel
lazyOptionModel
(String optionClassQualifiedName, String noneConstructor, String someConstructor) private SamInterface
lazySamInterface
(String samInterfaceQualifiedName) private List
<FreeVariable> merge
(List<FreeVariable> vbs1, List<FreeVariable> vbs2) object()
optionModel
(Flavour flavour) com.squareup.javapoet.MethodSpec.Builder
overrideMethodBuilder
(ExecutableElement abstractMethod, DeclaredType declaredType) com.squareup.javapoet.CodeBlock
parameterList
(DataConstructor constructor) com.squareup.javapoet.CodeBlock
parameterList
(DataConstructor constructor, String suffix) resolve
(DeclaredType declaredType, Function<TypeVariable, Optional<TypeMirror>> typeArgs) resolve
(TypeMirror typeMirror, Function<TypeVariable, Optional<TypeMirror>> typeArgs) resolveFieldInstances
(AlgebraicDataType adt, com.squareup.javapoet.ClassName typeClass, List<TypeElement> lowPriorityProviders) com.squareup.javapoet.TypeName
resolveToTypeName
(TypeMirror typeMirror, Function<TypeVariable, Optional<com.squareup.javapoet.TypeName>> typeArgs) samInterface
(String qualifiedClassName) typeRestrictions
(List<TypeRestriction> typeRestrictions) types()
typeVariablesIn
(TypeMirror typeMirror) private Stream
<TypeVariable> typeVariablesIn0
(TypeMirror typeMirror) uncapitalize
(CharSequence string) unify
(TypeMirror from, TypeMirror to) private Optional
<HashMap<TypeVariable, TypeMirror>> unify0
(TypeMirror from, TypeMirror to, HashMap<TypeVariable, TypeMirror> unified)
-
Field Details
-
Elements
-
Types
-
deriveConfigBuilder
-
objectModel
-
function0Model
-
function1Model
-
optionModel
-
eitherModel
-
-
Constructor Details
-
DeriveUtilsImpl
DeriveUtilsImpl(Elements Elements, Types Types, DeriveConfigBuilder deriveConfigBuilder)
-
-
Method Details
-
types
- Specified by:
types
in interfaceDeriveUtils
-
elements
- Specified by:
elements
in interfaceDeriveUtils
-
resolveToTypeName
public com.squareup.javapoet.TypeName resolveToTypeName(TypeMirror typeMirror, Function<TypeVariable, Optional<com.squareup.javapoet.TypeName>> typeArgs) - Specified by:
resolveToTypeName
in interfaceDeriveUtils
-
typeRestrictions
public Function<TypeVariable,Optional<TypeMirror>> typeRestrictions(List<TypeRestriction> typeRestrictions) - Specified by:
typeRestrictions
in interfaceDeriveUtils
-
resolve
public TypeMirror resolve(TypeMirror typeMirror, Function<TypeVariable, Optional<TypeMirror>> typeArgs) - Specified by:
resolve
in interfaceDeriveUtils
-
unify
- Specified by:
unify
in interfaceDeriveUtils
-
unify0
private Optional<HashMap<TypeVariable,TypeMirror>> unify0(TypeMirror from, TypeMirror to, HashMap<TypeVariable, TypeMirror> unified) -
resolve
public DeclaredType resolve(DeclaredType declaredType, Function<TypeVariable, Optional<TypeMirror>> typeArgs) - Specified by:
resolve
in interfaceDeriveUtils
-
overrideMethodBuilder
public com.squareup.javapoet.MethodSpec.Builder overrideMethodBuilder(ExecutableElement abstractMethod, DeclaredType declaredType) - Specified by:
overrideMethodBuilder
in interfaceDeriveUtils
-
typeVariablesIn
- Specified by:
typeVariablesIn
in interfaceDeriveUtils
-
allAbstractMethods
- Specified by:
allAbstractMethods
in interfaceDeriveUtils
-
allAbstractMethods
- Specified by:
allAbstractMethods
in interfaceDeriveUtils
-
allStaticMethods
- Specified by:
allStaticMethods
in interfaceDeriveUtils
-
allStaticFields
- Specified by:
allStaticFields
in interfaceDeriveUtils
-
asDeclaredType
- Specified by:
asDeclaredType
in interfaceDeriveUtils
-
asTypeElement
- Specified by:
asTypeElement
in interfaceDeriveUtils
-
isWildcarded
- Specified by:
isWildcarded
in interfaceDeriveUtils
-
object
- Specified by:
object
in interfaceDeriveUtils
-
samInterface
- Specified by:
samInterface
in interfaceDeriveUtils
-
function0Model
- Specified by:
function0Model
in interfaceDeriveUtils
-
function1Model
- Specified by:
function1Model
in interfaceDeriveUtils
-
optionModel
- Specified by:
optionModel
in interfaceDeriveUtils
-
eitherModel
- Specified by:
eitherModel
in interfaceDeriveUtils
-
uncapitalize
- Specified by:
uncapitalize
in interfaceDeriveUtils
-
capitalize
- Specified by:
capitalize
in interfaceDeriveUtils
-
findInstance
public Optional<InstanceLocation> findInstance(TypeElement typeElementContext, com.squareup.javapoet.ClassName typeClassContext, com.squareup.javapoet.ClassName typeClass, TypeElement typeElement, DeclaredType declaredType, List<TypeElement> lowPriorityProviders) - Specified by:
findInstance
in interfaceDeriveUtils
-
instanceInitializer
public DeriveResult<BoundExpression> instanceInitializer(TypeElement typeElementContext, com.squareup.javapoet.ClassName typeClassContext, com.squareup.javapoet.ClassName typeClass, TypeMirror type, List<TypeElement> lowPriorityProviders) - Specified by:
instanceInitializer
in interfaceDeriveUtils
-
resolveFieldInstances
public DeriveResult<FieldsTypeClassInstanceBindingMap> resolveFieldInstances(AlgebraicDataType adt, com.squareup.javapoet.ClassName typeClass, List<TypeElement> lowPriorityProviders) - Specified by:
resolveFieldInstances
in interfaceDeriveUtils
-
lambdaImpl
public com.squareup.javapoet.CodeBlock lambdaImpl(DataConstructor constructor, com.squareup.javapoet.CodeBlock impl) - Specified by:
lambdaImpl
in interfaceDeriveUtils
-
lambdaImpl
public com.squareup.javapoet.CodeBlock lambdaImpl(DataConstructor constructor, String suffix, com.squareup.javapoet.CodeBlock impl) - Specified by:
lambdaImpl
in interfaceDeriveUtils
-
generateInstance
public DeriveResult<DerivedCodeSpec> generateInstance(AlgebraicDataType adt, com.squareup.javapoet.ClassName typeClass, List<TypeElement> lowPriorityProviders, Function<InstanceUtils, DerivedCodeSpec> generateInstance) - Specified by:
generateInstance
in interfaceDeriveUtils
-
parameterList
- Specified by:
parameterList
in interfaceDeriveUtils
-
parameterList
- Specified by:
parameterList
in interfaceDeriveUtils
-
findTypeElement
- Specified by:
findTypeElement
in interfaceDeriveUtils
-
asTypeArguments
-
findFirstDeclaredTypeOf
-
instanceVariableName
-
generatedInstanceMethodName
-
allTypeArgsAsString
-
findCompiledInstance
private Optional<InstanceLocation> findCompiledInstance(TypeElement typeElementContext, TypeElement typeClass, TypeElement typeElement, DeclaredType declaredType, List<TypeElement> lowPriorityProviders, Optional<com.squareup.javapoet.ClassName> deriveTarget, Optional<com.squareup.javapoet.ClassName> deriveTargetExtend, Optional<com.squareup.javapoet.ClassName> contextExtend) -
findCompiledInstanceIn
private Function<TypeElement,Stream<InstanceLocation>> findCompiledInstanceIn(TypeElement typeElement, DeclaredType declaredType, Optional<com.squareup.javapoet.ClassName> deriveTarget, TypeMirror rawTypeClass) -
lazyOptionModel
private OptionModel lazyOptionModel(String optionClassQualifiedName, String noneConstructor, String someConstructor) -
eitherModel
private Optional<EitherModel> eitherModel(String eitherClassQualifiedName, String leftConstructor, String rightConstructor) -
lazySamInterface
-
typeVariablesIn0
-
abstractMethod
-
join
-
merge
-
isNotIn
-
join
private BoundExpression join(BinaryOperator<Expression> expressionJoiner, BoundExpression b1, BoundExpression b2) -
joinAsArgs
-
getSuperTypeElements
-