Class AttributeBuilderReflection.ThirdPartyAttributeBuilderStrategy
- java.lang.Object
-
- org.immutables.value.processor.meta.AttributeBuilderReflection.ThirdPartyAttributeBuilderStrategy
-
- All Implemented Interfaces:
AttributeBuilderReflection.Strategy
- Direct Known Subclasses:
ImmutableThirdPartyAttributeBuilderStrategy
- Enclosing class:
- AttributeBuilderReflection
@Immutable(builder=false) abstract static class AttributeBuilderReflection.ThirdPartyAttributeBuilderStrategy extends java.lang.Object implements AttributeBuilderReflection.Strategy
Strategy for parsing third party immutables. for example: the protocol buffer API. Assumes that all third party classes are available on the class path at processing time. If this is not the case, we may need to use a processing method that allows deferring of compilation. Example, moving from auto-value to immutables... though maybe you would just implement a new strategy for that use case...
-
-
Constructor Summary
Constructors Constructor Description ThirdPartyAttributeBuilderStrategy()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract javax.lang.model.element.TypeElementattributeValueType()Guaranteed not null if isAttributeBuilder is true.protected abstract AttributeBuilderThirdPartyModelbuilderModel()Guaranteed not null if isAttributeBuilder is true.AttributeBuilderDescriptorgetAttributeBuilderDescriptor()booleanisAttributeBuilder()private static booleanisPossibleBuilderClass(javax.lang.model.element.Element possibleBuilderClass, ValueAttribute valueAttribute)Determine if inner class could be a builder.private static booleanisPossibleBuilderMethod(javax.lang.model.element.Element possibleBuilderMethod, boolean onValueType, ValueAttribute valueAttribute)Return true if the possibleBuilderMethod matches the Style#attributeBuilder() and returns a class.private static booleanisPossibleBuildMethod(ValueAttribute attribute, javax.lang.model.element.Element possibleBuildMethod)Returns true if there's a public way to build the value type with an instance no-arg method.protected static booleanisPossibleCopyMethod(ValueAttribute valueAttribute, javax.lang.model.element.Element possibleCopyMethod, boolean onValueType)Applies to both builder and value candidates.(package private) static AttributeBuilderReflection.ThirdPartyAttributeBuilderStrategyof(ValueAttribute valueAttribute)private static voidprocessPossibleBuilder(ValueAttribute attribute, AttributeBuilderThirdPartyModel.Creator builderModel)
-
-
-
Method Detail
-
builderModel
@Nullable @Parameter protected abstract AttributeBuilderThirdPartyModel builderModel()
Guaranteed not null if isAttributeBuilder is true.- Returns:
- model of how to generate attributeBuilder.
-
attributeValueType
@Nullable @Parameter protected abstract javax.lang.model.element.TypeElement attributeValueType()
Guaranteed not null if isAttributeBuilder is true.- Returns:
- containingType of the value attribute.
-
isAttributeBuilder
public boolean isAttributeBuilder()
- Specified by:
isAttributeBuilderin interfaceAttributeBuilderReflection.Strategy
-
getAttributeBuilderDescriptor
@Nullable @Derived public AttributeBuilderDescriptor getAttributeBuilderDescriptor()
- Specified by:
getAttributeBuilderDescriptorin interfaceAttributeBuilderReflection.Strategy
-
of
static AttributeBuilderReflection.ThirdPartyAttributeBuilderStrategy of(ValueAttribute valueAttribute)
- Returns:
- strategy which has an AttributeBuilderDescriptor if attributeValue is an attributeBuilder.
-
processPossibleBuilder
private static void processPossibleBuilder(ValueAttribute attribute, AttributeBuilderThirdPartyModel.Creator builderModel)
-
isPossibleBuildMethod
private static boolean isPossibleBuildMethod(ValueAttribute attribute, javax.lang.model.element.Element possibleBuildMethod)
Returns true if there's a public way to build the value type with an instance no-arg method.- Parameters:
attribute- value attribute to check.possibleBuildMethod- method which matchesStyleMirror.attributeBuilder()- Returns:
- true if this is the possibleBuildMethod can build the value type.
-
isPossibleBuilderMethod
private static boolean isPossibleBuilderMethod(javax.lang.model.element.Element possibleBuilderMethod, boolean onValueType, ValueAttribute valueAttribute)Return true if the possibleBuilderMethod matches the Style#attributeBuilder() and returns a class. TODO: may need to make this return true if the return type is an interface too...- Parameters:
possibleBuilderMethod- executableElement
-
isPossibleBuilderClass
private static boolean isPossibleBuilderClass(javax.lang.model.element.Element possibleBuilderClass, ValueAttribute valueAttribute)Determine if inner class could be a builder.- Parameters:
possibleBuilderClass- nested value element that could be builder class.- Returns:
- true if it's a static inner class.
-
isPossibleCopyMethod
protected static boolean isPossibleCopyMethod(ValueAttribute valueAttribute, javax.lang.model.element.Element possibleCopyMethod, boolean onValueType)
Applies to both builder and value candidates.- Parameters:
valueAttribute- the valueAttribute.possibleCopyMethod- candidate to check.
-
-