# Class KeyValue

java.lang.Object
javafx.animation.KeyValue

public final class KeyValue extends Object
Defines a key value to be interpolated for a particular interval along the animation. A `KeyFrame`, which defines a specific point on a timeline, can hold multiple `KeyValues`. `KeyValue` is an immutable class.

A `KeyValue` is defined by a target, which is an implementation of `WritableValue`, an end value and an `Interpolator`.

Most interpolators define the interpolation between two `KeyFrames`. (The only exception are tangent-interpolators.) The `KeyValue` of the second `KeyFrame` (in forward direction) specifies the interpolator to be used in the interval.

Tangent-interpolators define the interpolation to the left and to the right of a `KeyFrame` (see `Interpolator.TANGENT`).

By default, `Interpolator.LINEAR` is used in the interval.

Since:
  JavaFX 2.0
See Also:
  - `Timeline`
  - `KeyFrame`
  - `Interpolator`

- ## Constructor Summary

  Constructors
  Modifier
  Constructor
  Description
  `<T>`
  `KeyValue(WritableValue<T> target, T endValue)`
  Creates a `KeyValue` that uses `Interpolator.LINEAR`.
  `<T>`
  `KeyValue(WritableValue<T> target, T endValue, Interpolator interpolator)`
  Creates a `KeyValue`.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `boolean`
  `equals(Object obj)`
  Indicates whether some other object is "equal to" this one.
  `Object`
  `getEndValue()`
  Returns the end value of this `KeyValue`
  `Interpolator`
  `getInterpolator()`
  `Interpolator` to be used for calculating the key value along the particular interval.
  `WritableValue<?>`
  `getTarget()`
  Returns the target of this `KeyValue`
  `int`
  `hashCode()`
  Returns a hash code for this `KeyValue` object.
  `String`
  `toString()`
  Returns a string representation of this `KeyValue` object.

  ### Methods declared in class Object

  `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- ## Constructor Details

  - ### KeyValue

    public <T> KeyValue(WritableValue<T> target, T endValue, Interpolator interpolator)
    Creates a `KeyValue`.
    Type Parameters:
      `T` - the type of the `KeyValue`
    Parameters:
      `target` - the target
      `endValue` - the end value
      `interpolator` - the `Interpolator`
    Throws:
      `NullPointerException` - if `target` or `interpolator` are `null`

  - ### KeyValue

    public <T> KeyValue(WritableValue<T> target, T endValue)
    Creates a `KeyValue` that uses `Interpolator.LINEAR`.
    Type Parameters:
      `T` - the type of the `KeyValue`
    Parameters:
      `target` - the target
      `endValue` - the end value
    Throws:
      `NullPointerException` - if `target` or `interpolator` are `null`

- ## Method Details

  - ### getTarget

    public WritableValue<?> getTarget()
    Returns the target of this `KeyValue`
    Returns:
      the target

  - ### getEndValue

    public Object getEndValue()
    Returns the end value of this `KeyValue`
    Returns:
      the end value

  - ### getInterpolator

    public Interpolator getInterpolator()
    `Interpolator` to be used for calculating the key value along the particular interval. By default, `Interpolator.LINEAR` is used.
    Returns:
      the interpolator to be used for calculating the key value along the particular interval

  - ### toString

    public String toString()
    Returns a string representation of this `KeyValue` object.
    Overrides:
      `toString` in class `Object`
    Returns:
      the string representation

  - ### hashCode

    public int hashCode()
    Returns a hash code for this `KeyValue` object.
    Overrides:
      `hashCode` in class `Object`
    Returns:
      the hash code

  - ### equals

    public boolean equals(Object obj)
    Indicates whether some other object is "equal to" this one. Two `KeyValues` are considered equal, if their `target`, `endValue`, and `interpolator` are equal.
    Overrides:
      `equals` in class `Object`