Package org.apache.tapestry5.commons.services

## Interface PropertyAdapter

- All Superinterfaces:
    `AnnotationProvider`
  All Known Implementing Classes:
    `PropertyAdapterImpl`

      public interface PropertyAdapter
      extends AnnotationProvider

  Provides access to a single property within a class. Acts as an `AnnotationProvider`; when searching for annotations, the read method (if present) is checked first, followed by the write method, followed by the underlying field (when the property name matches the field name). Starting in release 5.2, this property may actually be a public field. In 5.3, it may be a public static field.
  See Also:
    `ClassPropertyAdapter`

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `java.lang.Object` | `get​(java.lang.Object instance)` | Reads the property value.
    `java.lang.Class` | `getBeanType()` | Returns the type of bean to which this property belongs.
    `ClassPropertyAdapter` | `getClassAdapter()` | Returns the `ClassPropertyAdapter` that provides access to other properties defined by the same class.
    `java.lang.Class` | `getDeclaringClass()` | The class in which the property (or public field) is defined.
    `java.lang.reflect.Field` | `getField()` | Returns the field if the property is a public field or null if the property is accessed via the read method.
    `java.lang.String` | `getName()` | Returns the name of the property (or public field).
    `java.lang.reflect.Method` | `getReadMethod()` | Returns the method used to read the property, or null if the property is not readable (or is a public field).
    `java.lang.Class` | `getType()` | Returns the type of the property.
    `java.lang.reflect.Method` | `getWriteMethod()` | Returns the method used to update the property, or null if the property is not writeable (or a public field).
    `boolean` | `isCastRequired()` | Returns true if the return type of the read method is not the same as the property type.
    `boolean` | `isField()` | Returns true if the property is actually a public field (possibly, a public static field).
    `boolean` | `isRead()` | Returns true if the property is readable (i.e., has a getter method or is a public field).
    `boolean` | `isUpdate()` | Returns true if the property is writeable (i.e., has a setter method or is a non-final field).
    `void` | `set​(java.lang.Object instance, java.lang.Object value)` | Updates the property value.

    - ### Methods inherited from interface org.apache.tapestry5.commons.AnnotationProvider

      `getAnnotation`

- - ### Method Detail

    - #### getName

          java.lang.String getName()

      Returns the name of the property (or public field).

    - #### isRead

          boolean isRead()

      Returns true if the property is readable (i.e., has a getter method or is a public field).

    - #### getReadMethod

          java.lang.reflect.Method getReadMethod()

      Returns the method used to read the property, or null if the property is not readable (or is a public field).

    - #### isUpdate

          boolean isUpdate()

      Returns true if the property is writeable (i.e., has a setter method or is a non-final field).

    - #### getWriteMethod

          java.lang.reflect.Method getWriteMethod()

      Returns the method used to update the property, or null if the property is not writeable (or a public field).

    - #### get

          java.lang.Object get​(java.lang.Object instance)

      Reads the property value.
      Parameters:
        `instance` - to read from
      Throws:
        `java.lang.UnsupportedOperationException` - if the property is write only

    - #### set

          void set​(java.lang.Object instance,
                   java.lang.Object value)

      Updates the property value. The provided value must not be null if the property type is primitive, and must otherwise be of the proper type.
      Parameters:
        `instance` - to update
        `value` - new value for the property
      Throws:
        `java.lang.UnsupportedOperationException` - if the property is read only

    - #### getType

          java.lang.Class getType()

      Returns the type of the property.

    - #### isCastRequired

          boolean isCastRequired()

      Returns true if the return type of the read method is not the same as the property type. This can occur when the property has been defined using generics, in which case, the method's type may be Object when the property type is something more specific. This method is primarily used when generating runtime code related to the property.

    - #### getClassAdapter

          ClassPropertyAdapter getClassAdapter()

      Returns the `ClassPropertyAdapter` that provides access to other properties defined by the same class.

    - #### getBeanType

          java.lang.Class getBeanType()

      Returns the type of bean to which this property belongs. This is the same as `ClassPropertyAdapter.getBeanType()`.

    - #### isField

          boolean isField()

      Returns true if the property is actually a public field (possibly, a public static field).
      Since:
        5.2

    - #### getField

          java.lang.reflect.Field getField()

      Returns the field if the property is a public field or null if the property is accessed via the read method.
      Since:
        5.2

    - #### getDeclaringClass

          java.lang.Class getDeclaringClass()

      The class in which the property (or public field) is defined.
      Since:
        5.2