diff --git a/plugins/git4idea/src/git4idea/GitReference.java b/plugins/git4idea/src/git4idea/GitReference.java index 5025d5b23f10..4d6c8d56f789 100644 --- a/plugins/git4idea/src/git4idea/GitReference.java +++ b/plugins/git4idea/src/git4idea/GitReference.java @@ -17,31 +17,20 @@ package git4idea; import org.jetbrains.annotations.NotNull; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashSet; -import java.util.Set; - /** - * The base class for named git references + * The base class for named git references, like branches and tags. */ public abstract class GitReference implements Comparable { - /** - * The name of the reference - */ - protected final String myName; - /** - * The constructor - * - * @param name the used name - */ + @NotNull protected final String myName; + public GitReference(@NotNull String name) { myName = new String(name); } /** - * @return the local name of the reference + * @return the name of the reference, e.g. "origin/master" or "feature". + * @see #getFullName() */ @NotNull public String getName() { @@ -49,70 +38,28 @@ public abstract class GitReference implements Comparable { } /** - * @return the full name of the object + * @return the full name of the reference, e.g. "refs/remotes/origin/master" or "refs/heads/master". */ @NotNull public abstract String getFullName(); - /** - * @return the full name for the reference ({@link #getFullName()}. - */ @Override public String toString() { return getFullName(); } - /** - * {@inheritDoc} - */ @Override - public boolean equals(final Object obj) { + public boolean equals(Object obj) { return obj instanceof GitReference && - toString().equals(obj.toString()); //To change body of overridden methods use File | Settings | File Templates. + toString().equals(obj.toString()); } - /** - * {@inheritDoc} - */ @Override public int hashCode() { return toString().hashCode(); } - /** - * {@inheritDoc} - */ - public int compareTo(final GitReference o) { + public int compareTo(GitReference o) { return o == null ? 1 : getFullName().compareTo(o.getFullName()); } - - /** - * Get name clashes for the for the sequence of the collections - * - * @param collections the collection list - * @return the conflict set - */ - public static Set getNameClashes(Collection... collections) { - ArrayList> individual = new ArrayList>(); - // collect individual key sets - for (Collection c : collections) { - HashSet s = new HashSet(); - individual.add(s); - for (GitReference r : c) { - s.add(r.getName()); - } - } - HashSet rc = new HashSet(); - // all pairs from array - for (int i = 0; i < collections.length - 1; i++) { - HashSet si = individual.get(i); - for (int j = i + 1; j < collections.length; j++) { - HashSet sj = individual.get(i); - final HashSet copy = new HashSet(si); - copy.retainAll(sj); - rc.addAll(copy); - } - } - return rc; - } }