Diff (Apache Commons Lang 3.20.0 API)
Description: declaration: package: org.apache.commons.lang3.builder, class: Diff

# Class Diff<T>

java.lang.Object
org.apache.commons.lang3.tuple.Pair<T,T>
org.apache.commons.lang3.builder.Diff<T>

Type Parameters:
  `T` - The type of object contained within this `Diff`. Differences between primitive objects are stored as their Object wrapper equivalent.

All Implemented Interfaces:
  `Serializable, Comparable<Pair<T,T>>, Map.Entry<T,T>`

public abstract class Diff<T> extends Pair<T,T>
A `Diff` contains the differences between two `Diffable` class fields.

Typically, `Diff`s are retrieved by using a `DiffBuilder` to produce a `DiffResult`, containing the differences between two objects.

Since:
  3.3
See Also:
  - Serialized Form

- ## Field Summary

  ### Fields inherited from class Pair

  `EMPTY_ARRAY`

- ## Constructor Summary

  Constructors
  Modifier
  Constructor
  Description
  `protected`
  `Diff(String fieldName)`
  Constructs a new `Diff` for the given field name.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `final String`
  `getFieldName()`
  Gets the name of the field.
  `final Type`
  `getType()`
  Deprecated.
  Unused, will be removed in 4.0.0.
  `final T`
  `setValue(T value)`
  Throws `UnsupportedOperationException`.
  `final String`
  `toString()`
  Returns a `String` representation of the `Diff`, with the following format:

  ### Methods inherited from class Pair

  `accept, apply, compareTo, emptyArray, equals, getKey, getLeft, getRight, getValue, hashCode, of, of, ofNonNull, toString`

  ### Methods inherited from class Object

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

- ## Constructor Details

  - ### Diff

    protected Diff(String fieldName)
    Constructs a new `Diff` for the given field name.
    Parameters:
      `fieldName` - the field name.

- ## Method Details

  - ### getFieldName

    public final String getFieldName()
    Gets the name of the field.
    Returns:
      the field name.

  - ### getType

    @Deprecated public final Type getType()
    Deprecated.
    Unused, will be removed in 4.0.0.
    Gets the type of the field.
    Returns:
      the field type.

  - ### setValue

    public final T setValue(T value)
    Throws `UnsupportedOperationException`.
    Parameters:
      `value` - ignored.
    Returns:
      Throws `UnsupportedOperationException`.

  - ### toString

    public final String toString()
    Returns a `String` representation of the `Diff`, with the following format:

        [fieldname: left-value, right-value]

    Overrides:
      `toString` in class `Pair<T,T>`
    Returns:
      the string representation.