MetaProperty (Groovy 5.1.0)
Description: declaration: package: groovy.lang, class: MetaProperty

Package groovy.lang

# Class MetaProperty

java.lang.Object
groovy.lang.MetaProperty

All Implemented Interfaces:
  `MetaMember`

Direct Known Subclasses:
  `CachedField`, `MetaArrayLengthProperty`, `MetaBeanProperty`, `MetaExpandoProperty`, `MethodMetaProperty`, `MultipleSetterProperty`

public abstract class MetaProperty extends Object implements MetaMember
Represents a property on a bean which may have a getter and/or a setter

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `protected final String`
  `name`
  `static final String`
  `PROPERTY_SET_PREFIX`
  `protected Class`
  `type`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `MetaProperty(String name, Class type)`
  Constructor that sets the property name and type (class)

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static String`
  `getGetterName(String propertyName, Class type)`
  Gets the name for the getter for this property
  `int`
  `getModifiers()`
  Returns the access modifiers.
  `String`
  `getName()`
  Returns the name of the property.
  `abstract Object`
  `getProperty(Object object)`
  `static String`
  `getSetterName(String propertyName)`
  Gets the setter for the getter for this property.
  `Class`
  `getType()`
  Returns the ntypeame of the property.
  `abstract void`
  `setProperty(Object object, 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`

  ### Methods inherited from interface groovy.lang.MetaMember

  `isFinal, isPackagePrivate, isPrivate, isProtected, isPublic, isStatic, isSynthetic`

- ## Field Details

  - ### PROPERTY_SET_PREFIX

    public static final String PROPERTY_SET_PREFIX
    See Also:
      - Constant Field Values

  - ### name

    protected final String name

  - ### type

    protected Class type

- ## Constructor Details

  - ### MetaProperty

    public MetaProperty(String name, Class type)
    Constructor that sets the property name and type (class)

- ## Method Details

  - ### getProperty

    public abstract Object getProperty(Object object)
    Returns:
      the property of the given object
    Throws:
      `RuntimeException` - if the property could not be evaluated

  - ### setProperty

    public abstract void setProperty(Object object, 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:
      `RuntimeException` - if the property could not be set

  - ### getName

    public String getName()
    Returns the name of the property.
    Specified by:
      `getName` in interface `MetaMember`
    Returns:
      the name of the property

  - ### getType

    public Class getType()
    Returns the ntypeame of the property.
    Returns:
      the type of the property

  - ### getModifiers

    public int getModifiers()
    Returns the access modifiers.
    Specified by:
      `getModifiers` in interface `MetaMember`
    Returns:
      `Modifier.PUBLIC`

  - ### getGetterName

    public static String getGetterName(String propertyName, 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 String getSetterName(String propertyName)
    Gets the setter for the getter for this property.
    Returns:
      The name of the property. The name is "set"+ the capitalized propertyName.