Class ModifyValue<T>

  • All Implemented Interfaces:
    Command

    public abstract class ModifyValue<T>
    extends CommandImpl
    The goal of this abstract command is to modify an object. This object can be for instance a property of an object. The use of this command can be made when an object has a lot of properties which modification follow the same process. Thus, a same command can be used to modify all the properties. To do so, a enumeration of the properties can be defined and used into the command to specify which property will be modified by the current command instance.
    Author:
    Arnaud Blouin
    • Field Detail

      • value

        protected T value
        The new value of the property.
    • Constructor Detail

      • ModifyValue

        public ModifyValue()
        Initialises the command.
      • ModifyValue

        public ModifyValue​(T value)
        Initialises the command with the value to set.
        Parameters:
        value - The value to set.
    • Method Detail

      • flush

        public void flush()
        Description copied from interface: Command
        Flushes the command. Can be useful to close streams, free objects, etc. A command should flushed manually only when it is not managed by the cmd registry of the application. When a command is gathered and managed by a command registry, it is automatically flushed when the command registry removes the cmd.
        Specified by:
        flush in interface Command
        Overrides:
        flush in class CommandImpl
      • canDo

        public boolean canDo()
        Description copied from interface: Command
        Checks whether the command can be executed.
        Specified by:
        canDo in interface Command
        Overrides:
        canDo in class CommandImpl
        Returns:
        True if the command can be executed.
      • setValue

        public void setValue​(T newValue)
        Sets the new value of the parameter to change.
        Parameters:
        newValue - The new value.
      • applyValue

        protected abstract void applyValue​(T obj)
        This method executes the job of methods undo, redo, and do
        Parameters:
        obj - The value to set. Must not be null.
        Throws:
        NullPointerException - If the given value is null.
      • isValueMatchesProperty

        protected abstract boolean isValueMatchesProperty()
        Returns:
        True: the object to modified supports the selected property.