org.apache.commons.collections4.sequence

## Class EditCommand<T>

- java.lang.Object
- - org.apache.commons.collections4.sequence.EditCommand<T>

- Direct Known Subclasses:
    DeleteCommand, InsertCommand, KeepCommand

      public abstract class EditCommand<T>
      extends Object

  Abstract base class for all commands used to transform an objects sequence into another one.

  When two objects sequences are compared through the `SequencesComparator.getScript` method, the result is provided has a `script` containing the commands that progressively transform the first sequence into the second one.

  There are only three types of commands, all of which are subclasses of this abstract class. Each command is associated with one object belonging to at least one of the sequences. These commands are `InsertCommand` which correspond to an object of the second sequence being inserted into the first sequence, `DeleteCommand` which correspond to an object of the first sequence being removed and `KeepCommand` which correspond to an object of the first sequence which `equals` an object in the second sequence. It is guaranteed that comparison is always performed this way (i.e. the `equals` method of the object from the first sequence is used and the object passed as an argument comes from the second sequence) ; this can be important if subclassing is used for some elements in the first sequence and the `equals` method is specialized.

  Since:
    4.0
  Version:
    $Id: EditCommand.java 1477760 2013-04-30 18:34:03Z tn $
  See Also:
    `SequencesComparator`, `EditScript`

- - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `EditCommand(T object)` Simple constructor.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `abstract void` | `accept(CommandVisitor<T> visitor)` Accept a visitor.
    `protected T` | `getObject()` Returns the object associated with this command.

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

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

- - ### Constructor Detail

    - #### EditCommand

          protected EditCommand(T object)

      Simple constructor. Creates a new instance of EditCommand
      Parameters:
        `object` - reference to the object associated with this command, this refers to an element of one of the sequences being compared

  - ### Method Detail

    - #### getObject

          protected T getObject()

      Returns the object associated with this command.
      Returns:
        the object on which the command is applied

    - #### accept

          public abstract void accept(CommandVisitor<T> visitor)

      Accept a visitor.

      This method is invoked for each commands belonging to an `EditScript`, in order to implement the visitor design pattern

      Parameters:
        `visitor` - the visitor to be accepted

Copyright © 2001–2015 The Apache Software Foundation. All rights reserved.