Class AbstractCommand

  • All Implemented Interfaces:
    Command
    Direct Known Subclasses:
    Arrange, Clean, Infer, Make, Mark, Publish

    public abstract class AbstractCommand
    extends Object
    implements Command
    The common superclass for Nyx commands. This class is not meant to be used in multi-threaded environments. All implementing classes must have a public constructor that accept a State and a Repository parameter.
    • Constructor Detail

      • AbstractCommand

        protected AbstractCommand​(State state,
                                  Repository repository)
        Standard constructor.
        Parameters:
        state - the state reference
        repository - the repository reference
        Throws:
        NullPointerException - if a given argument is null
    • Method Detail

      • state

        public final State state()
        Returns the state object.
        Specified by:
        state in interface Command
        Returns:
        the state object that was passed in the constructor (never null, even when or after Command.run() returns null).
      • repository

        public final Repository repository()
        Returns the repository object.
        Returns:
        the repository object.
      • getLatestCommit

        protected String getLatestCommit()
                                  throws GitException
        Returns the SHA-1 identifier of the last commit in the current branch.
        Returns:
        the SHA-1 identifier of the last commit in the current branch or code if the repository has no commits yet.
        Throws:
        GitException - in case of unexpected issues when accessing the Git repository.
        See Also:
        repository()
      • isRepositoryClean

        protected boolean isRepositoryClean()
                                     throws GitException
        Returns true if the repository is in a clean state (no uncommitted changes).
        Returns:
        true if the repository is in a clean state (no uncommitted changes).
        Throws:
        GitException - in case of unexpected issues when accessing the Git repository.
        See Also:
        repository()