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 Details

    • ThirdPartyAttributeBuilderStrategy

      ThirdPartyAttributeBuilderStrategy()
  • Method Details

    • 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 TypeElement attributeValueType()
      Guaranteed not null if isAttributeBuilder is true.
      Returns:
      containingType of the value attribute.
    • isAttributeBuilder

      public boolean isAttributeBuilder()
      Specified by:
      isAttributeBuilder in interface AttributeBuilderReflection.Strategy
    • getAttributeBuilderDescriptor

      @Nullable @Derived public AttributeBuilderDescriptor getAttributeBuilderDescriptor()
      Specified by:
      getAttributeBuilderDescriptor in interface AttributeBuilderReflection.Strategy
    • of

      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, 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 matches StyleMirror.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.