]> source.dussan.org Git - jgit.git/commitdiff
Use static factory methods instead of overloaded constructors 53/19053/2
authorStefan Lay <stefan.lay@sap.com>
Thu, 28 Nov 2013 10:18:16 +0000 (11:18 +0100)
committerStefan Lay <stefan.lay@sap.com>
Fri, 29 Nov 2013 08:34:03 +0000 (09:34 +0100)
Change-Id: Ib10e0798dcfb9f1b611caec393926c95eff4c2a2

org.eclipse.jgit/src/org/eclipse/jgit/api/RebaseCommand.java
org.eclipse.jgit/src/org/eclipse/jgit/api/RebaseResult.java

index d077cff15649afb00c27f851e2a2e9ec4e991392..3bbac4a856aac76be59508ce459884bebbab9a48 100644 (file)
@@ -321,7 +321,7 @@ public class RebaseCommand extends GitCommand<RebaseResult> {
                        }
                        return finishRebase(newHead, lastStepWasForward);
                } catch (CheckoutConflictException cce) {
-                       return new RebaseResult(cce.getConflictingPaths());
+                       return RebaseResult.conflicts(cce.getConflictingPaths());
                } catch (IOException ioe) {
                        throw new JGitInternalException(ioe.getMessage(), ioe);
                }
@@ -340,7 +340,7 @@ public class RebaseCommand extends GitCommand<RebaseResult> {
                RevCommit commitToPick = walk.parseCommit(ids.iterator().next());
                if (shouldPick) {
                        if (monitor.isCancelled())
-                               return new RebaseResult(commitToPick, Status.STOPPED);
+                               return RebaseResult.result(Status.STOPPED, commitToPick);
                        RebaseResult result = cherryPickCommit(commitToPick);
                        if (result != null)
                                return result;
@@ -403,8 +403,8 @@ public class RebaseCommand extends GitCommand<RebaseResult> {
                                switch (cherryPickResult.getStatus()) {
                                case FAILED:
                                        if (operation == Operation.BEGIN)
-                                               return abort(new RebaseResult(
-                                                               cherryPickResult.getFailingPaths()));
+                                               return abort(RebaseResult.failed(cherryPickResult
+                                                               .getFailingPaths()));
                                        else
                                                return stop(commitToPick, Status.STOPPED);
                                case CONFLICTING:
@@ -735,7 +735,7 @@ public class RebaseCommand extends GitCommand<RebaseResult> {
                // Remove cherry pick state file created by CherryPickCommand, it's not
                // needed for rebase
                repo.writeCherryPickHead(null);
-               return new RebaseResult(commitToPick, status);
+               return RebaseResult.result(status, commitToPick);
        }
 
        String toAuthorScript(PersonIdent author) {
index aaa75d9b8897915423c852c304653e60027d567c..0587b4301837730cac278aa1a2ed646319eb3b30 100644 (file)
@@ -190,16 +190,22 @@ public class RebaseResult {
                currentCommit = null;
        }
 
+       private RebaseResult(Status status, RevCommit commit) {
+               this.status = status;
+               currentCommit = commit;
+       }
+
        /**
-        * Create <code>RebaseResult</code> with status {@link Status#STOPPED}
+        * Create <code>RebaseResult</code>
         *
+        * @param status
         * @param commit
         *            current commit
-        * @param status
+        * @return the RebaseResult
         */
-       RebaseResult(RevCommit commit, RebaseResult.Status status) {
-               this.status = status;
-               currentCommit = commit;
+       static RebaseResult result(RebaseResult.Status status,
+                       RevCommit commit) {
+               return new RebaseResult(status, commit);
        }
 
        /**
@@ -207,11 +213,13 @@ public class RebaseResult {
         *
         * @param failingPaths
         *            list of paths causing this rebase to fail
+        * @return the RebaseResult
         */
-       RebaseResult(Map<String, MergeFailureReason> failingPaths) {
-               status = Status.FAILED;
-               currentCommit = null;
-               this.failingPaths = failingPaths;
+       static RebaseResult failed(
+                       Map<String, MergeFailureReason> failingPaths) {
+               RebaseResult result = new RebaseResult(Status.FAILED);
+               result.failingPaths = failingPaths;
+               return result;
        }
 
        /**
@@ -219,11 +227,12 @@ public class RebaseResult {
         *
         * @param conflicts
         *            the list of conflicting paths
+        * @return the RebaseResult
         */
-       RebaseResult(List<String> conflicts) {
-               status = Status.CONFLICTS;
-               currentCommit = null;
-               this.conflicts = conflicts;
+       static RebaseResult conflicts(List<String> conflicts) {
+               RebaseResult result = new RebaseResult(Status.CONFLICTS);
+               result.conflicts = conflicts;
+               return result;
        }
 
        /**