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
public abstract class GitCommand<T> extends Object implements Callable<T>
Common superclass of all commands in the packageorg.eclipse.jgit.api
This class ensures that all commands fulfill the
Callable
interface. It also has a propertyrepo
holding a reference to the gitRepository
this command should work with.Finally this class stores a state telling whether it is allowed to call
call()
on this instance. Instances ofGitCommand
can only be used for one single successful call tocall()
. Afterwards this instance may not be used anymore to set/modify any properties or to callcall()
again. This is achieved by setting thecallable
property to false after the successful execution ofcall()
and to check the state (by callingcheckCallable()
) before setting of properties and insidecall()
.
-
-
Field Summary
Fields Modifier and Type Field Description protected Repository
repo
The repository this command is working with
-
Constructor Summary
Constructors Modifier Constructor Description protected
GitCommand(Repository repo)
Creates a new command which interacts with a single repository
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract T
call()
protected void
checkCallable()
Checks that the propertycallable
istrue
.Repository
getRepository()
Get repository this command is working onprotected void
setCallable(boolean callable)
Set's the state which tells whether it is allowed to callcall()
on this instance.
-
-
-
Field Detail
-
repo
protected final Repository repo
The repository this command is working with
-
-
Constructor Detail
-
GitCommand
protected GitCommand(Repository repo)
Creates a new command which interacts with a single repository- Parameters:
repo
- theRepository
this command should interact with
-
-
Method Detail
-
getRepository
public Repository getRepository()
Get repository this command is working on- Returns:
- the
Repository
this 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
- iftrue
it is allowed to callcall()
on this instance.
-
checkCallable
protected void checkCallable()
- Throws:
IllegalStateException
- when this method is called and the propertycallable
isfalse
-
call
public abstract T call() throws GitAPIException
Execute the command
- Specified by:
call
in interfaceCallable<T>
- Throws:
GitAPIException
-
-