Package org.apache.tapestry5.plastic

## Interface PlasticField

- All Superinterfaces:
    `AnnotationAccess`

      public interface PlasticField
      extends AnnotationAccess

  Represents a field of a class being transformed. No methods of this object should be invoked after the class transformation is completed.

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `PlasticField` | `claim​(java.lang.Object tag)` | Claims the field, used to indicate that the field is "processed".
    `PlasticField` | `createAccessors​(PropertyAccessType accessType)` | Creates access to the field, using the default property name derived from the name of the field.
    `PlasticField` | `createAccessors​(PropertyAccessType accessType, java.lang.String propertyName)` | Creates accessors, possibly replacing existing methods (or overriding methods from a super class).
    `java.lang.String` | `getGenericSignature()` | Returns the field's fully qualified generic type, or null if not defined.
    `FieldHandle` | `getHandle()` | Returns a handle that can be used to directly access a private field of a transformed class instance.
    `int` | `getModifiers()` | Returns the modifiers on the field.
    `java.lang.String` | `getName()` | Returns the name of the field.
    `PlasticClass` | `getPlasticClass()` | Returns the class containing this field.
    `java.lang.String` | `getTypeName()` | Returns the fully qualified class name for the field's type or (for a primitive type) the primitive type name ("int", "char", etc.).
    `PlasticField` | `inject​(java.lang.Object value)` | Converts the field to be read-only, and provide the indicated value.
    `PlasticField` | `injectComputed​(ComputedValue<?> computedValue)` | Converts the field to be read-only, and provide the value, which is computed indirectly inside the class' constructor.
    `PlasticField` | `injectFromInstanceContext()` | As with `inject(Object)`, but the value is extracted from the `InstanceContext`.
    `boolean` | `isClaimed()` | Returns true if the field has already been claimed.
    `<F> PlasticField` | `setComputedConduit​(ComputedValue<FieldConduit<F>> computedConduit)` | Sets the conduit for the field to a value computed when the class is instantiated
    `<F> PlasticField` | `setConduit​(FieldConduit<F> conduit)` | Intercepts all access to the field, replacing such access with calls on the conduit.

    - ### Methods inherited from interface org.apache.tapestry5.plastic.AnnotationAccess

      `getAnnotation, hasAnnotation`

- - ### Method Detail

    - #### getPlasticClass

          PlasticClass getPlasticClass()

      Returns the class containing this field.

    - #### getHandle

          FieldHandle getHandle()

      Returns a handle that can be used to directly access a private field of a transformed class instance.

    - #### getName

          java.lang.String getName()

      Returns the name of the field.

    - #### getTypeName

          java.lang.String getTypeName()

      Returns the fully qualified class name for the field's type or (for a primitive type) the primitive type name ("int", "char", etc.). For array types, the returned name includes a "[]" suffix.

    - #### claim

          PlasticField claim​(java.lang.Object tag)

      Claims the field, used to indicate that the field is "processed". A field may only be claimed once. Claiming a field is intended as a mechanism to detect or prevent conflicts between different isolated transformations of the field. The tag value used does not matter, and is typically either an annotation (that drove the transformation) or the instance of `PlasticClassTransformer` that performed the transformation. That tag value is only used when generating the error message for the case where a field is claimed for than once.
      Returns:
        the field for further manipulation
      Throws:
        `java.lang.RuntimeException` - if the field is claimed a second time
        `java.lang.AssertionError` - if tag is null
      See Also:
        `PlasticClass.getUnclaimedFields()`

    - #### isClaimed

          boolean isClaimed()

      Returns true if the field has already been claimed.
      See Also:
        `PlasticClass.getUnclaimedFields()`

    - #### inject

          PlasticField inject​(java.lang.Object value)

      Converts the field to be read-only, and provide the indicated value. The field's value will be set inside the class' constructor.
      Parameters:
        `value` - to inject, which must be type compatible with the field (possibly, a wrapper type if the field is a primitive value). The value may not be null.
      Returns:
        the field for further manipulation
      Throws:
        `java.lang.IllegalStateException` - if the field already has an injection, or the field has a conduit

    - #### injectComputed

          PlasticField injectComputed​(ComputedValue<?> computedValue)

      Converts the field to be read-only, and provide the value, which is computed indirectly inside the class' constructor.
      Parameters:
        `computedValue` - provides the actual value to be injected, and must return a value type compatible with the field (possibly a wrapper type if the field is a primitive value). The computedValue may not be null.
      Returns:
        the field for further manipulation
      Throws:
        `java.lang.IllegalStateException` - if the field already has an injection, or the field has a conduit

    - #### injectFromInstanceContext

          PlasticField injectFromInstanceContext()

      As with `inject(Object)`, but the value is extracted from the `InstanceContext`.
      Returns:
        this field for further manipulation

    - #### setConduit

          <F> PlasticField setConduit​(FieldConduit<F> conduit)

      Intercepts all access to the field, replacing such access with calls on the conduit. Even access via the FieldHandle will instead delegate to the conduit. Once a conduit is provided, it is not possible to inject a value into the field. Normally, once a conduit is in place, the field will never be actually read or written. This is problematic for debugging, so `TransformationOption.FIELD_WRITEBEHIND` is useful when operating in a non-production mode.
      Returns:
        the field for further manipulation
      Throws:
        `java.lang.IllegalStateException` - if the field already has an injection or a conduit

    - #### setComputedConduit

          <F> PlasticField setComputedConduit​(ComputedValue<FieldConduit<F>> computedConduit)

      Sets the conduit for the field to a value computed when the class is instantiated
      Parameters:
        `computedConduit` - object that will compute the actual conduit to be used
      Returns:
        this field for further manipulation

    - #### createAccessors

          PlasticField createAccessors​(PropertyAccessType accessType)

      Creates access to the field, using the default property name derived from the name of the field. The default property name is the same as the name of the field, but with any leading or trailing underscore characters removed (a common convention among some programmers). Also, strips leading "m_" from the field name (another common convention).
      Parameters:
        `accessType` - which methods to create
      Returns:
        the field for further manipulation
      Throws:
        `java.lang.IllegalArgumentException` - if an accessor method to be created already exists (possibly inherited from a base class)

    - #### createAccessors

          PlasticField createAccessors​(PropertyAccessType accessType,
                                       java.lang.String propertyName)

      Creates accessors, possibly replacing existing methods (or overriding methods from a super class). The method names consist of the property name, with its first character converted to upper-case, prefixed with "get" or "set". The accessor methods must not already exist.
      Parameters:
        `accessType` - which methods to create
        `propertyName` - the name of the property (from which the names of the methods are generated)
      Returns:
        the field for further manipulation
      Throws:
        `java.lang.IllegalArgumentException` - if an accessor method to be created already exists (possibly inherited from a base class)

    - #### getGenericSignature

          java.lang.String getGenericSignature()

      Returns the field's fully qualified generic type, or null if not defined.

    - #### getModifiers

          int getModifiers()

      Returns the modifiers on the field.