Package groovy.lang

Class MetaProperty

java.lang.Object
groovy.lang.MetaProperty
Direct Known Subclasses:
CachedField, MetaArrayLengthProperty, MetaBeanProperty, MetaExpandoProperty, MethodMetaProperty, MultipleSetterProperty

public abstract class MetaProperty
extends java.lang.Object
Represents a property on a bean which may have a getter and/or a setter
  • Field Summary

    Fields
    Modifier and Type Field Description
    protected java.lang.String name  
    static java.lang.String PROPERTY_SET_PREFIX  
    protected java.lang.Class type  
  • Constructor Summary

    Constructors
    Constructor Description
    MetaProperty​(java.lang.String name, java.lang.Class type)
    Constructor that sets the property name and type (class)
  • Method Summary

    Modifier and Type Method Description
    static java.lang.String getGetterName​(java.lang.String propertyName, java.lang.Class type)
    Gets the name for the getter for this property
    int getModifiers()
    Returns the access modifier.
    java.lang.String getName()
    Return the name of the property
    abstract java.lang.Object getProperty​(java.lang.Object object)  
    static java.lang.String getSetterName​(java.lang.String propertyName)
    Gets the setter for the getter for this property.
    java.lang.Class getType()  
    abstract void setProperty​(java.lang.Object object, java.lang.Object newValue)
    Sets the property on the given object to the new value

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • name

      protected final java.lang.String name
    • type

      protected java.lang.Class type
    • PROPERTY_SET_PREFIX

      public static final java.lang.String PROPERTY_SET_PREFIX
      See Also:
      Constant Field Values
  • Constructor Details

    • MetaProperty

      public MetaProperty​(java.lang.String name, java.lang.Class type)
      Constructor that sets the property name and type (class)
  • Method Details

    • getProperty

      public abstract java.lang.Object getProperty​(java.lang.Object object)
      Returns:
      the property of the given object
      Throws:
      java.lang.Exception - if the property could not be evaluated
    • setProperty

      public abstract void setProperty​(java.lang.Object object, java.lang.Object newValue)
      Sets the property on the given object to the new value
      Parameters:
      object - on which to set the property
      newValue - the new value of the property
      Throws:
      java.lang.RuntimeException - if the property could not be set
    • getName

      public java.lang.String getName()
      Return the name of the property
      Returns:
      the name of the property
    • getType

      public java.lang.Class getType()
      Returns:
      the type of the property
    • getModifiers

      public int getModifiers()
      Returns the access modifier.
      Returns:
      Modifier.PUBLIC
    • getGetterName

      public static java.lang.String getGetterName​(java.lang.String propertyName, java.lang.Class type)
      Gets the name for the getter for this property
      Returns:
      The name of the property. The name is "get"+ the capitalized propertyName or, in the case of boolean values, "is" + the capitalized propertyName
    • getSetterName

      public static java.lang.String getSetterName​(java.lang.String propertyName)
      Gets the setter for the getter for this property.
      Returns:
      The name of the property. The name is "set"+ the capitalized propertyName.