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 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 -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract TypeElementGuaranteed not null if isAttributeBuilder is true.protected abstract AttributeBuilderThirdPartyModelGuaranteed not null if isAttributeBuilder is true.booleanprivate static booleanisPossibleBuilderClass(Element possibleBuilderClass, ValueAttribute valueAttribute) Determine if inner class could be a builder.private static booleanisPossibleBuilderMethod(Element possibleBuilderMethod, boolean onValueType, ValueAttribute valueAttribute) Return true if the possibleBuilderMethod matches the Style#attributeBuilder() and returns a class.private static booleanisPossibleBuildMethod(ValueAttribute attribute, 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, 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)
-
Constructor Details
-
ThirdPartyAttributeBuilderStrategy
ThirdPartyAttributeBuilderStrategy()
-
-
Method Details
-
builderModel
Guaranteed not null if isAttributeBuilder is true.- Returns:
- model of how to generate attributeBuilder.
-
attributeValueType
Guaranteed not null if isAttributeBuilder is true.- Returns:
- containingType of the value attribute.
-
isAttributeBuilder
public boolean isAttributeBuilder()- Specified by:
isAttributeBuilderin interfaceAttributeBuilderReflection.Strategy
-
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
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(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(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, Element possibleCopyMethod, boolean onValueType) Applies to both builder and value candidates.- Parameters:
valueAttribute- the valueAttribute.possibleCopyMethod- candidate to check.
-