Class AggregateChange<T>

java.lang.Object
net.officefloor.model.impl.change.AggregateChange<T>
All Implemented Interfaces:
Change<T>

public class AggregateChange<T> extends Object implements Change<T>
Aggregates multiple Change instances into a single Change.
Author:
Daniel Sagenschneider
  • Constructor Details

    • AggregateChange

      public AggregateChange(T target, String changeDescription, Change<?>... changes)
      Initiate.
      Parameters:
      target - Target.
      changeDescription - Change description.
      changes - Change instances.
  • Method Details

    • aggregate

      public static <T> Change<T> aggregate(Change<T> change, Change<?>... changes)
      Aggregates the Change instances, basing resulting Change on first Change.
      Type Parameters:
      T - Target type.
      Parameters:
      change - First Change.
      changes - Further Change instances to aggregate.
      Returns:
      Change aggregating the input Change instances.
    • getTarget

      public T getTarget()
      Description copied from interface: Change
      Obtains the target to which this Change applies.
      Specified by:
      getTarget in interface Change<T>
      Returns:
      Target to which this Change applies.
    • getChangeDescription

      public String getChangeDescription()
      Description copied from interface: Change
      Obtains a description of the Change.
      Specified by:
      getChangeDescription in interface Change<T>
      Returns:
      Description of the Change.
    • canApply

      public boolean canApply()
      Description copied from interface: Change

      Indicates if can apply this Change.

      Typically there will be Conflict instances providing detail on why the Change can not be applied.

      Specified by:
      canApply in interface Change<T>
      Returns:
      true if can apply this Change.
      See Also:
    • apply

      public void apply()
      Description copied from interface: Change
      Applies this Change.
      Specified by:
      apply in interface Change<T>
    • revert

      public void revert()
      Description copied from interface: Change

      Reverts this Change (after being applied).

      This enables do/undo functionality.

      Specified by:
      revert in interface Change<T>
    • getConflicts

      public Conflict[] getConflicts()
      Description copied from interface: Change

      Obtains the Conflict instances preventing this Change from being applied.

      A Change can only be applied if this returns an empty array.

      Specified by:
      getConflicts in interface Change<T>
      Returns:
      Any Conflict instances preventing applying this Change.