Interface AutoValueExtension.Context

  • Enclosing class:
    AutoValueExtension

    public static interface AutoValueExtension.Context
    The context of the generation cycle.
    • Method Detail

      • packageName

        String packageName()
        Returns the package name of the classes to be generated.
      • autoValueClass

        TypeElement autoValueClass()
        Returns the annotated class that this generation cycle is based on.

        Given @AutoValue public class Foo {...}, this will be Foo.

      • properties

        Map<String,​ExecutableElement> properties()
        Returns the ordered collection of properties to be generated by AutoValue. Each key is a property name, and the corresponding value is the getter method for that property. For example, if property bar is defined by abstract String getBar() then this map will have an entry mapping "bar" to the ExecutableElement for getBar().

        To determine the type of a property, it is best to use propertyTypes() rather than looking at the return type of the ExecutableElement in this map. The reason is that the final type of the property might be different because of type variables. For example, if you have...

           interface Parent<T> {
             T bar();
           }
          @AutoValue abstract class Foo implements Parent<String> {...}
        ...then the type of the bar property in Foo is actually String, but the ExecutableElement will be the the method in Parent, whose return type is T.
      • propertyTypes

        default Map<String,​TypeMirror> propertyTypes()
        Returns the properties to be generated by AutoValue, with their types. Each key is a property name, and the corresponding value is the type of that property. The order of the map entries is the same as the order of the @AutoValue properties.

        For example, if property bar is defined by abstract String getBar() then this map will have an entry mapping "bar" to the TypeMirror for String.

        For compatibility reasons, this method has a default implementation that throws an exception. The AutoValue processor supplies an implementation that behaves as documented.

      • abstractMethods

        Set<ExecutableElement> abstractMethods()
        Returns the complete set of abstract methods defined in or inherited by the @AutoValue class. This includes all methods that define properties (like abstract String getBar()), any abstract toBuilder() method, and any other abstract method even if it has been consumed by this or another Extension.
      • classAnnotationsToCopy

        default List<AnnotationMirror> classAnnotationsToCopy​(TypeElement classToCopyFrom)
        Returns the complete list of annotations defined on the classToCopyFrom that should be added to any generated subclass. Only annotations visible to the @AutoValue will be present. See AutoValue.CopyAnnotations for more information.

        The default implementation of this method returns an empty list for compatibility with extensions which may have implemented this interface themselves.

      • methodAnnotationsToCopy

        default List<AnnotationMirror> methodAnnotationsToCopy​(ExecutableElement method)
        Returns the complete list of annotations defined on the method that should be applied to any override of that method. Only annotations visible to the @AutoValue will be present. See AutoValue.CopyAnnotations for more information.

        The default implementation of this method returns an empty list for compatibility with extensions which may have implemented this interface themselves.