Class Property

All Implemented Interfaces:
Annotatable, Attributeable, Commentable, Node, Renderable

public class Property extends ModifierSupport implements Renderable, Commentable, Annotatable
  • Constructor Details

  • Method Details

    • newProperty

      public static Property newProperty(String name)
    • newProperty

      public static Property newProperty(Class type, String name)
    • newProperty

      public static Property newProperty(TypeRef typeRef, String name)
    • getAnnotations

      public List<AnnotationRef> getAnnotations()
      Specified by:
      getAnnotations in interface Annotatable
    • getTypeRef

      public TypeRef getTypeRef()
    • getName

      public String getName()
    • getComments

      public List<String> getComments()
      Description copied from interface: Commentable
      Get the list of comments.
      Specified by:
      getComments in interface Commentable
      Returns:
      a List of comments.
    • isEnumConstant

      public boolean isEnumConstant()
    • isSynthetic

      public boolean isSynthetic()
    • getInitialValue

      public Optional<Expression> getInitialValue()
    • getNameCapitalized

      public String getNameCapitalized()
    • getReferences

      public Set<ClassRef> getReferences()
    • withoutModiers

      protected Property withoutModiers()
      This is only used for rendering method arguments, where we usually string modifiers.
      Returns:
      the property without any modifiers
    • withErasure

      public Property withErasure()
      Get the property after the type erasure is applied. This in essense means that the type parameters are replaced by Object.
      Returns:
      the 'erased` property.
    • withoutInitialValue

      public Property withoutInitialValue()
      Get the property without its initial value.
      Returns:
      the property.
    • withInitialValue

      public Property withInitialValue(Object initialValue)
      Get the property with the specified object as iniital value.
      Parameters:
      initialValue - an Object
      Returns:
      the property.
    • withInitialValue

      public Property withInitialValue(Expression initialValue)
      Get the property with the specified object as iniital value.
      Parameters:
      initialValue - an Expression
      Returns:
      the property.
    • withInitialValue

      public Property withInitialValue(Optional<Expression> initialValue)
      Get the property with the specified initial value
      Parameters:
      initialValue - an Optional Expression
      Returns:
      the property.
    • getDefaultValue

      @Deprecated protected String getDefaultValue()
      Deprecated.
      Get the default value of the property The mehotd is deprecated, use getInitialValue() instead.
      Returns:
      String the default value of the Property
    • toReference

      public PropertyRef toReference()
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • render

      public String render()
      Description copied from interface: Renderable
      Render the type into a String for the purpose of code generation. This is slightly different from the `toString()` method as `toString()` is mostly needed for logging / debugging and should be idempotent. Regarding idempotency this method may yield different result based on the context it is used even if the internal state of the object does not change. An example of such case, is a reference to class that may change based on the package from which it's refenced.
      Specified by:
      render in interface Renderable
      Returns:
      the String representation of the object as it's meant to appear in the generated code.
    • toString

      public String toString()
      Overrides:
      toString in class Object