Package com.singularsys.jep.misc.boundvariable

# Class FieldVariableBinding

java.lang.Object
com.singularsys.jep.misc.boundvariable.FieldVariableBinding

All Implemented Interfaces:
  `VariableBinding`, `Serializable`

public class FieldVariableBinding extends Object implements VariableBinding
A `VariableBinding` which binds variables to a particular field of an object. Uses the reflection mechanism of `Class.getField(String)`.

Since:
  Jep 3.5
Author:
  Richard Morris
See Also:
  - Serialized Form

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `protected Field`
  `field`
  `protected final String`
  `fieldName`
  `protected final Object`
  `obj`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `FieldVariableBinding(Object obj, Field field)`
  Create the binding object with the name of a field.
  `FieldVariableBinding(Object obj, String fieldName)`
  Create the binding object with the name of a field.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `Object`
  `getValue()`
  Gets the value of the associated field.
  `void`
  `setValue(Object value)`
  Sets the value of the associated field.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### obj

    protected final Object obj

  - ### fieldName

    protected final String fieldName

  - ### field

    protected Field field

- ## Constructor Details

  - ### FieldVariableBinding

    public FieldVariableBinding(Object obj, String fieldName) throws SecurityException, NoSuchFieldException
    Create the binding object with the name of a field.
    Parameters:
      `obj` - the object
      `fieldName` - the name of the field
    Throws:
      `SecurityException` - if the field can not be accessed.
      `NoSuchFieldException` - if the field does not exist.

  - ### FieldVariableBinding

    public FieldVariableBinding(Object obj, Field field)
    Create the binding object with the name of a field.
    Parameters:
      `obj` - the object
      `field` - a field object

- ## Method Details

  - ### getValue

    public Object getValue() throws IllegalArgumentException, IllegalAccessException
    Gets the value of the associated field.
    Specified by:
      `getValue` in interface `VariableBinding`
    Returns:
      the value
    Throws:
      `IllegalArgumentException`
      `IllegalAccessException`
    See Also:
      - `Field.get(Object)`

  - ### setValue

    public void setValue(Object value) throws IllegalArgumentException, IllegalAccessException
    Sets the value of the associated field.
    Specified by:
      `setValue` in interface `VariableBinding`
    Parameters:
      `value` - the value
    Throws:
      `IllegalArgumentException`
      `IllegalAccessException`
    See Also:
      - `Field.set(Object, Object)`