-
Notifications
You must be signed in to change notification settings - Fork 182
Add type parameter for Command interface #1273
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
kwin
wants to merge
1
commit into
master
Choose a base branch
from
feature/command-with-generics
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -29,16 +29,17 @@ | |
| /** | ||
| * @author <a href="mailto:[email protected]">Emmanuel Venisse</a> | ||
| * @author <a href="mailto:[email protected]">Trygve Laugstøl</a> | ||
| * @param <T> | ||
| * | ||
| */ | ||
| public abstract class AbstractCommand implements Command { | ||
| public abstract class AbstractCommand<T extends ScmResult> implements Command<T> { | ||
| protected Logger logger = LoggerFactory.getLogger(getClass()); | ||
|
|
||
| protected abstract ScmResult executeCommand( | ||
| protected abstract T executeCommand( | ||
| ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) throws ScmException; | ||
|
|
||
| /** {@inheritDoc} */ | ||
| public final ScmResult execute(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) | ||
| public final T execute(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) | ||
| throws ScmException { | ||
| if (repository == null) { | ||
| throw new NullPointerException("repository cannot be null"); | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,9 +27,9 @@ | |
| /** | ||
| * @author <a href="mailto:[email protected]">Emmanuel Venisse</a> | ||
| * @author <a href="mailto:[email protected]">Trygve Laugstøl</a> | ||
| * | ||
| * @param <T> the type of result returned by this command | ||
| */ | ||
| public interface Command { | ||
| public interface Command<T extends ScmResult> { | ||
| /** Plexus component key */ | ||
| String ROLE = Command.class.getName(); | ||
|
|
||
|
|
@@ -40,6 +40,5 @@ public interface Command { | |
| * @return the result object | ||
| * @throws ScmException if any | ||
| */ | ||
| ScmResult execute(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) | ||
| throws ScmException; | ||
| T execute(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) throws ScmException; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,20 +22,19 @@ | |
| import org.apache.maven.scm.CommandParameters; | ||
| import org.apache.maven.scm.ScmException; | ||
| import org.apache.maven.scm.ScmFileSet; | ||
| import org.apache.maven.scm.ScmResult; | ||
| import org.apache.maven.scm.command.AbstractCommand; | ||
| import org.apache.maven.scm.provider.ScmProviderRepository; | ||
|
|
||
| /** | ||
| * @author <a href="mailto:[email protected]">Trygve Laugstøl</a> | ||
| * | ||
| */ | ||
| public abstract class AbstractAddCommand extends AbstractCommand { | ||
| protected abstract ScmResult executeAddCommand( | ||
| public abstract class AbstractAddCommand extends AbstractCommand<AddScmResult> { | ||
| protected abstract AddScmResult executeAddCommand( | ||
| ScmProviderRepository repository, ScmFileSet fileSet, String message, boolean binary) throws ScmException; | ||
|
|
||
| /** {@inheritDoc} */ | ||
| protected ScmResult executeCommand( | ||
| protected AddScmResult executeCommand( | ||
| ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) throws ScmException { | ||
| return executeAddCommand( | ||
| repository, | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,7 +24,6 @@ | |
| import org.apache.maven.scm.ScmBranchParameters; | ||
| import org.apache.maven.scm.ScmException; | ||
| import org.apache.maven.scm.ScmFileSet; | ||
| import org.apache.maven.scm.ScmResult; | ||
| import org.apache.maven.scm.command.AbstractCommand; | ||
| import org.apache.maven.scm.provider.ScmProviderRepository; | ||
|
|
||
|
|
@@ -33,8 +32,8 @@ | |
| * @author <a href="mailto:[email protected]">Trygve Laugstøl</a> | ||
| * | ||
| */ | ||
| public abstract class AbstractBranchCommand extends AbstractCommand { | ||
| protected abstract ScmResult executeBranchCommand( | ||
| public abstract class AbstractBranchCommand extends AbstractCommand<BranchScmResult> { | ||
| protected abstract BranchScmResult executeBranchCommand( | ||
| ScmProviderRepository repository, ScmFileSet fileSet, String branchName, String message) | ||
| throws ScmException; | ||
|
|
||
|
|
@@ -48,7 +47,7 @@ protected abstract ScmResult executeBranchCommand( | |
| * @return TODO | ||
| * @throws ScmException if any | ||
| */ | ||
| protected ScmResult executeBranchCommand( | ||
| protected BranchScmResult executeBranchCommand( | ||
| ScmProviderRepository repository, | ||
| ScmFileSet fileSet, | ||
| String branchName, | ||
|
|
@@ -58,8 +57,8 @@ protected ScmResult executeBranchCommand( | |
| } | ||
|
|
||
| /** {@inheritDoc} */ | ||
| public ScmResult executeCommand(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) | ||
| throws ScmException { | ||
| public BranchScmResult executeCommand( | ||
| ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) throws ScmException { | ||
| String branchName = parameters.getString(CommandParameter.BRANCH_NAME); | ||
|
|
||
| ScmBranchParameters scmBranchParameters = | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,7 +22,6 @@ | |
| import org.apache.maven.scm.CommandParameters; | ||
| import org.apache.maven.scm.ScmException; | ||
| import org.apache.maven.scm.ScmFileSet; | ||
| import org.apache.maven.scm.ScmResult; | ||
| import org.apache.maven.scm.ScmVersion; | ||
| import org.apache.maven.scm.command.AbstractCommand; | ||
| import org.apache.maven.scm.provider.ScmProviderRepository; | ||
|
|
@@ -37,14 +36,14 @@ | |
| * @author <a href="mailto:[email protected]">Brett Porter</a> | ||
| * | ||
| */ | ||
| public abstract class AbstractDiffCommand extends AbstractCommand { | ||
| public abstract class AbstractDiffCommand extends AbstractCommand<DiffScmResult> { | ||
| protected abstract DiffScmResult executeDiffCommand( | ||
| ScmProviderRepository repository, ScmFileSet fileSet, ScmVersion startRevision, ScmVersion endRevision) | ||
| throws ScmException; | ||
|
|
||
| /** {@inheritDoc} */ | ||
| public ScmResult executeCommand(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) | ||
| throws ScmException { | ||
| public DiffScmResult executeCommand( | ||
| ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) throws ScmException { | ||
| ScmVersion startRevision = parameters.getScmVersion(CommandParameter.START_SCM_VERSION, null); | ||
|
|
||
| ScmVersion endRevision = parameters.getScmVersion(CommandParameter.END_SCM_VERSION, null); | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,7 +22,6 @@ | |
| import org.apache.maven.scm.CommandParameters; | ||
| import org.apache.maven.scm.ScmException; | ||
| import org.apache.maven.scm.ScmFileSet; | ||
| import org.apache.maven.scm.ScmResult; | ||
| import org.apache.maven.scm.ScmVersion; | ||
| import org.apache.maven.scm.command.AbstractCommand; | ||
| import org.apache.maven.scm.provider.ScmProviderRepository; | ||
|
|
@@ -31,13 +30,13 @@ | |
| * @author <a href="mailto:[email protected]">Emmanuel Venisse</a> | ||
| * | ||
| */ | ||
| public abstract class AbstractExportCommand extends AbstractCommand { | ||
| public abstract class AbstractExportCommand extends AbstractCommand<ExportScmResult> { | ||
| protected abstract ExportScmResult executeExportCommand( | ||
| ScmProviderRepository repository, ScmFileSet fileSet, ScmVersion scmVersion, String outputDirectory) | ||
| throws ScmException; | ||
|
|
||
| /** {@inheritDoc} */ | ||
| protected ScmResult executeCommand( | ||
| protected ExportScmResult executeCommand( | ||
| ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) throws ScmException { | ||
| ScmVersion scmVersion = parameters.getScmVersion(CommandParameter.SCM_VERSION, null); | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,9 +30,9 @@ | |
| /** | ||
| * @author <a href="mailto:[email protected]">Emmanuel Venisse</a> | ||
| * @author <a href="mailto:[email protected]">Trygve Laugstøl</a> | ||
| * | ||
| * // TODO: remove this class as it doesn't have any implementation | ||
| */ | ||
| public abstract class AbstractFileInfoCommand extends AbstractCommand { | ||
| public abstract class AbstractFileInfoCommand extends AbstractCommand<ScmResult> { | ||
| protected abstract ScmResult executeFileInfoCommand( | ||
| ScmProviderRepository repository, File workingDirectory, String filename) throws ScmException; | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,6 +26,7 @@ | |
| /** | ||
| * @author <a href="mailto:[email protected]">Kenney Westerhof</a> | ||
| * @author Olivier Lamy | ||
| * TODO: which command uses this class? | ||
| * | ||
| */ | ||
| public class InfoScmResult extends ScmResult { | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,7 +22,6 @@ | |
| import org.apache.maven.scm.CommandParameters; | ||
| import org.apache.maven.scm.ScmException; | ||
| import org.apache.maven.scm.ScmFileSet; | ||
| import org.apache.maven.scm.ScmResult; | ||
| import org.apache.maven.scm.ScmVersion; | ||
| import org.apache.maven.scm.command.AbstractCommand; | ||
| import org.apache.maven.scm.provider.ScmProviderRepository; | ||
|
|
@@ -31,7 +30,7 @@ | |
| * @author <a href="mailto:[email protected]">Carlos Sanchez</a> | ||
| * | ||
| */ | ||
| public abstract class AbstractListCommand extends AbstractCommand { | ||
| public abstract class AbstractListCommand extends AbstractCommand<ListScmResult> { | ||
| /** | ||
| * List contents of the remote repository | ||
| * | ||
|
|
@@ -47,8 +46,8 @@ protected abstract ListScmResult executeListCommand( | |
| throws ScmException; | ||
|
|
||
| /** {@inheritDoc} */ | ||
| public ScmResult executeCommand(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) | ||
| throws ScmException { | ||
| public ListScmResult executeCommand( | ||
| ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) throws ScmException { | ||
| if (fileSet.getFileList().isEmpty()) { | ||
| throw new IllegalArgumentException("fileSet can not be empty"); | ||
| } | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,20 +21,19 @@ | |
| import org.apache.maven.scm.CommandParameters; | ||
| import org.apache.maven.scm.ScmException; | ||
| import org.apache.maven.scm.ScmFileSet; | ||
| import org.apache.maven.scm.ScmResult; | ||
| import org.apache.maven.scm.command.AbstractCommand; | ||
| import org.apache.maven.scm.provider.ScmProviderRepository; | ||
|
|
||
| /** | ||
| * @author <a href="mailto:[email protected]">Emmanuel Venisse</a> | ||
| * | ||
| */ | ||
| public abstract class AbstractLoginCommand extends AbstractCommand { | ||
| public abstract class AbstractLoginCommand extends AbstractCommand<LoginScmResult> { | ||
| public abstract LoginScmResult executeLoginCommand( | ||
| ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) throws ScmException; | ||
|
|
||
| /** {@inheritDoc} */ | ||
| protected ScmResult executeCommand( | ||
| protected LoginScmResult executeCommand( | ||
| ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) throws ScmException { | ||
| return executeLoginCommand(repository, fileSet, parameters); | ||
| } | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,15 +22,14 @@ | |
| import org.apache.maven.scm.CommandParameters; | ||
| import org.apache.maven.scm.ScmException; | ||
| import org.apache.maven.scm.ScmFileSet; | ||
| import org.apache.maven.scm.ScmResult; | ||
| import org.apache.maven.scm.command.AbstractCommand; | ||
| import org.apache.maven.scm.provider.ScmProviderRepository; | ||
|
|
||
| /** | ||
| * @author <a href="mailto:[email protected]">Maria Odea Ching</a> | ||
| * | ||
| */ | ||
| public abstract class AbstractMkdirCommand extends AbstractCommand { | ||
| public abstract class AbstractMkdirCommand extends AbstractCommand<MkdirScmResult> { | ||
| /** | ||
| * Creates directories in the remote repository. | ||
| * | ||
|
|
@@ -46,7 +45,7 @@ protected abstract MkdirScmResult executeMkdirCommand( | |
| throws ScmException; | ||
|
|
||
| /** {@inheritDoc} */ | ||
| protected ScmResult executeCommand( | ||
| protected MkdirScmResult executeCommand( | ||
| ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) throws ScmException { | ||
| if (fileSet.getFileList().isEmpty()) { | ||
| throw new IllegalArgumentException("fileSet can not be empty"); | ||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@olamy Is this backwards-compatible enough? It won't affect consumers as
ScmProviderdoes not use this. I consider this a SPI only interface (so only https://github.com/olamy/maven-scm-provider-svnjava would be affected).