Class AutoValueOrOneOfProcessor.Property

  • Enclosing class:
    AutoValueOrOneOfProcessor

    public static class AutoValueOrOneOfProcessor.Property
    extends java.lang.Object
    A property of an @AutoValue or @AutoOneOf class, defined by one of its abstract methods. An instance of this class is made available to the Velocity template engine for each property. The public methods of this class define JavaBeans-style properties that are accessible from templates. For example getType() means we can write $p.type for a Velocity variable $p that is a Property.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private com.google.common.collect.ImmutableList<java.lang.String> annotations  
      private java.lang.String identifier  
      private javax.lang.model.element.ExecutableElement method  
      private java.lang.String name  
      private java.util.Optional<java.lang.String> nullableAnnotation  
      private Optionalish optional  
      private java.lang.String type  
    • Constructor Summary

      Constructors 
      Constructor Description
      Property​(java.lang.String name, java.lang.String identifier, javax.lang.model.element.ExecutableElement method, java.lang.String type, com.google.common.collect.ImmutableList<java.lang.String> annotations, java.util.Optional<java.lang.String> nullableAnnotation)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean equals​(java.lang.Object obj)  
      java.lang.String getAccess()  
      java.util.List<java.lang.String> getAnnotations()  
      java.lang.String getGetter()
      Returns the name of the getter method for this property as defined by the @AutoValue class.
      javax.lang.model.type.TypeKind getKind()  
      java.lang.String getName()
      Returns the name of the property as it should be used in strings visible to users.
      java.lang.String getNullableAnnotation()
      Returns the string to use as a method annotation to indicate the nullability of this property.
      Optionalish getOptional()
      Returns an Optionalish representing the kind of Optional that this property's type is, or null if the type is not an Optional of any kind.
      java.lang.String getType()  
      javax.lang.model.type.TypeMirror getTypeMirror()  
      int hashCode()  
      boolean isNullable()  
      java.lang.String toString()
      Returns the name of the property as it should be used when declaring identifiers (fields and parameters).
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Field Detail

      • name

        private final java.lang.String name
      • identifier

        private final java.lang.String identifier
      • method

        private final javax.lang.model.element.ExecutableElement method
      • type

        private final java.lang.String type
      • annotations

        private final com.google.common.collect.ImmutableList<java.lang.String> annotations
      • nullableAnnotation

        private final java.util.Optional<java.lang.String> nullableAnnotation
    • Constructor Detail

      • Property

        Property​(java.lang.String name,
                 java.lang.String identifier,
                 javax.lang.model.element.ExecutableElement method,
                 java.lang.String type,
                 com.google.common.collect.ImmutableList<java.lang.String> annotations,
                 java.util.Optional<java.lang.String> nullableAnnotation)
    • Method Detail

      • toString

        public java.lang.String toString()
        Returns the name of the property as it should be used when declaring identifiers (fields and parameters). If the original getter method was foo() then this will be foo. If it was getFoo() then it will be foo. If it was getPackage() then it will be something like package0, since package is a reserved word.
        Overrides:
        toString in class java.lang.Object
      • getName

        public java.lang.String getName()
        Returns the name of the property as it should be used in strings visible to users. This is usually the same as toString(), except that if we had to use an identifier like "package0" because "package" is a reserved word, the name here will be the original "package".
      • getGetter

        public java.lang.String getGetter()
        Returns the name of the getter method for this property as defined by the @AutoValue class. For property foo, this will be foo or getFoo or isFoo.
      • getTypeMirror

        public javax.lang.model.type.TypeMirror getTypeMirror()
      • getType

        public java.lang.String getType()
      • getKind

        public javax.lang.model.type.TypeKind getKind()
      • getAnnotations

        public java.util.List<java.lang.String> getAnnotations()
      • getOptional

        public Optionalish getOptional()
        Returns an Optionalish representing the kind of Optional that this property's type is, or null if the type is not an Optional of any kind.
      • getNullableAnnotation

        public final java.lang.String getNullableAnnotation()
        Returns the string to use as a method annotation to indicate the nullability of this property. It is either the empty string, if the property is not nullable, or an annotation string with a trailing space, such as "@`javax.annotation.Nullable` ", where the `` is the encoding used by TypeEncoder. If the property is nullable by virtue of its type rather than its method being @Nullable, this method returns the empty string, because the @Nullable will appear when the type is spelled out. In this case, nullableAnnotation is present but empty.
      • isNullable

        public boolean isNullable()
      • getAccess

        public java.lang.String getAccess()
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object