Class Command


  • public class Command
    extends Object
    Command to create, update or delete an entry inside a RefTree.

    Unlike ReceiveCommand (which can only update a reference to an ObjectId), a RefTree Command can also create, modify or delete symbolic references to a target reference.

    RefTree Commands may wrap a ReceiveCommand to allow callers to process an existing ReceiveCommand against a RefTree.

    Commands should be passed into RefTree.apply(java.util.Collection) for processing.

    • Constructor Detail

      • Command

        public Command​(@Nullable
                       Ref oldRef,
                       @Nullable
                       Ref newRef)
        Create a command to create, update or delete a reference.

        At least one of oldRef or newRef must be supplied.

        Parameters:
        oldRef - expected value. Null if the ref should not exist.
        newRef - desired value, must be peeled if not null and not symbolic. Null to delete the ref.
    • Method Detail

      • getRefName

        public String getRefName()
        Get name of the reference affected by this command.
        Returns:
        name of the reference affected by this command.
      • setResult

        public void setResult​(ReceiveCommand.Result result)
        Set the result of this command.
        Parameters:
        result - the command result.
      • setResult

        public void setResult​(ReceiveCommand.Result result,
                              @Nullable
                              String why)
        Set the result of this command.
        Parameters:
        result - the command result.
        why - optional message explaining the result status.
      • getResult

        public ReceiveCommand.Result getResult()
        Get result of executing this command.
        Returns:
        result of executing this command.
      • getMessage

        @Nullable
        public String getMessage()
        Get optional message explaining command failure.
        Returns:
        optional message explaining command failure.
      • getOldRef

        @Nullable
        public Ref getOldRef()
        Old peeled reference.
        Returns:
        the old reference; null if the command is creating the reference.
      • getNewRef

        @Nullable
        public Ref getNewRef()
        New peeled reference.
        Returns:
        the new reference; null if the command is deleting the reference.