Package org.eclipse.jgit.api
Class GitCommand<T>
java.lang.Object
org.eclipse.jgit.api.GitCommand<T>
- Type Parameters:
T- the return type which is expected fromcall()
- All Implemented Interfaces:
Callable<T>
- Direct Known Subclasses:
AddCommand,AddNoteCommand,ApplyCommand,ArchiveCommand,BlameCommand,CheckoutCommand,CherryPickCommand,CleanCommand,CommitCommand,CreateBranchCommand,DeleteBranchCommand,DeleteTagCommand,DescribeCommand,DiffCommand,GarbageCollectCommand,ListBranchCommand,ListNotesCommand,ListTagCommand,LogCommand,MergeCommand,NameRevCommand,RebaseCommand,ReflogCommand,RemoteAddCommand,RemoteListCommand,RemoteRemoveCommand,RemoteSetUrlCommand,RemoveNoteCommand,RenameBranchCommand,RepoCommand,ResetCommand,RevertCommand,RmCommand,ShowNoteCommand,StashApplyCommand,StashCreateCommand,StashDropCommand,StashListCommand,StatusCommand,SubmoduleDeinitCommand,SubmoduleInitCommand,SubmoduleStatusCommand,SubmoduleSyncCommand,TagCommand,TransportCommand,VerifySignatureCommand
Common superclass of all commands in the package
org.eclipse.jgit.api
This class ensures that all commands fulfill the
Callable interface. It also has a property
repo holding a reference to the git
Repository this command should work with.
Finally this class stores a state telling whether it is allowed to call
call() on this instance. Instances of
GitCommand can only be used for one single
successful call to call(). Afterwards this instance may not be used
anymore to set/modify any properties or to call call() again. This
is achieved by setting the callable property to false after the
successful execution of call() and to check the state (by calling
checkCallable()) before setting of properties and inside
call().
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate AtomicBooleana state which tells whether it is allowed to callcall()on this instance.protected final RepositoryThe repository this command is working with -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedGitCommand(Repository repo) Creates a new command which interacts with a single repository -
Method Summary
Modifier and TypeMethodDescriptionabstract Tcall()protected voidChecks that the propertycallableistrue.Get repository this command is working onprotected voidsetCallable(boolean callable) Set's the state which tells whether it is allowed to callcall()on this instance.
-
Field Details
-
repo
The repository this command is working with -
callable
a state which tells whether it is allowed to callcall()on this instance.
-
-
Constructor Details
-
GitCommand
Creates a new command which interacts with a single repository- Parameters:
repo- theRepositorythis command should interact with
-
-
Method Details
-
getRepository
Get repository this command is working on- Returns:
- the
Repositorythis command is interacting with
-
setCallable
protected void setCallable(boolean callable) Set's the state which tells whether it is allowed to callcall()on this instance.checkCallable()will throw an exception when called and this property is set tofalse- Parameters:
callable- iftrueit is allowed to callcall()on this instance.
-
checkCallable
protected void checkCallable()- Throws:
IllegalStateException- when this method is called and the propertycallableisfalse
-
call
Execute the command
- Specified by:
callin interfaceCallable<T>- Throws:
GitAPIException
-