T
- the return type which is expected from call()
public abstract class GitCommand<T> extends Object implements Callable<T>
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()
.
Modifier and Type | Field and Description |
---|---|
protected Repository |
repo
The repository this command is working with
|
Modifier | Constructor and Description |
---|---|
protected |
GitCommand(Repository repo)
Creates a new command which interacts with a single repository
|
Modifier and Type | Method and Description |
---|---|
abstract T |
call() |
protected void |
checkCallable()
Checks that the property
callable is true . |
Repository |
getRepository()
Get repository this command is working on
|
protected void |
setCallable(boolean callable)
Set's the state which tells whether it is allowed to call
call()
on this instance. |
protected final Repository repo
protected GitCommand(Repository repo)
repo
- the Repository
this command
should interact withpublic Repository getRepository()
Repository
this command is
interacting withprotected void setCallable(boolean callable)
call()
on this instance. checkCallable()
will throw an exception when
called and this property is set to false
callable
- if true
it is allowed to call call()
on
this instance.protected void checkCallable()
IllegalStateException
- when this method is called and the property callable
is false
public abstract T call() throws GitAPIException
Execute the command
call
in interface Callable<T>
GitAPIException
Copyright © 2020 Eclipse JGit Project. All rights reserved.