Interface BuilderFrameworkSupport

All Known Implementing Classes:
AutoValueSupport, LombokSupport

public interface BuilderFrameworkSupport
Provides hooks to add CalledMethods annotations to code generated by a builder framework like Lombok or AutoValue. If you are adding support to the Called Methods Checker for a new builder framework, you should create a subclass of this class and modify the private method enableFramework in CalledMethodsAnnotatedTypeFactory.

Every method in this class is permitted to do nothing (or always return false). The work that each method must do is particular to the builder framework being supported.

  • Method Details

    • isToBuilderMethod

      boolean isToBuilderMethod(ExecutableElement candidateToBuilderElement)
      Returns true if a method is a toBuilder method on a type generated by the builder framework.
      Parameters:
      candidateToBuilderElement - a method
      Returns:
      true if candidateToBuilderElement is a toBuilder method on a type generated by the builder framework
    • handleToBuilderMethod

      void handleToBuilderMethod(AnnotatedTypeMirror.AnnotatedExecutableType toBuilderType)
      Hook for supporting a builder framework's toBuilder routine. Typically, the returned Builder has had all of its required setters invoked. So, implementations of this method should add a CalledMethods annotation capturing this fact.
      Parameters:
      toBuilderType - the type of a method that is the toBuilder method (as determined by isToBuilderMethod(ExecutableElement)) for a type that has an associated builder
    • isBuilderBuildMethod

      boolean isBuilderBuildMethod(ExecutableElement candidateBuildElement)
      Returns true if a method is a build method on a Builder type for the builder framework.
      Parameters:
      candidateBuildElement - a method
      Returns:
      true if candidateBuildElement is a build method on a Builder type for the builder framework
    • handleBuilderBuildMethod

      void handleBuilderBuildMethod(AnnotatedTypeMirror.AnnotatedExecutableType builderBuildType)
      Hook for adding annotations to a build() method (i.e. a finalizer) generated by a builder framework.

      For build methods on Builder types, implementations of this method should determine the required properties and add a corresponding CalledMethods annotation to the type of the receiver parameter.

      Parameters:
      builderBuildType - the type of a method that is the build method (as determined by isBuilderBuildMethod(ExecutableElement)) for a builder
    • handleConstructor

      void handleConstructor(NewClassTree tree, AnnotatedTypeMirror type)
      Hook for adding annotations (e.g., @CalledMethods) to a constructor call.
      Parameters:
      tree - a constructor call
      type - type of the call expression