[git] Better fix of equals & hashcode for GitRepoInfo

We consider GitRepoInfos as equal if, in particular,
they have the same set of remotes, while the order of these remotes
in collection is not interesting.
(Remotes are (or may be) supplied as ArrayLists, while equals for the
ArrayList considers the order of the elements).

Use LinkedHashSet to preserve the original ordering,
but use the needed equality definition.
This commit is contained in:
Kirill Likhodedov
2013-07-11 15:22:13 +04:00
parent b3b079fbe2
commit 764617d741
@@ -22,6 +22,8 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Collection;
import java.util.LinkedHashSet;
import java.util.Set;
/**
* @author Kirill Likhodedov
@@ -31,10 +33,10 @@ public class GitRepoInfo {
@Nullable private final GitLocalBranch myCurrentBranch;
@Nullable private final String myCurrentRevision;
@NotNull private final Repository.State myState;
@NotNull private final Collection<GitRemote> myRemotes;
@NotNull private final Collection<GitLocalBranch> myLocalBranches;
@NotNull private final Collection<GitRemoteBranch> myRemoteBranches;
@NotNull private final Collection<GitBranchTrackInfo> myBranchTrackInfos;
@NotNull private final Set<GitRemote> myRemotes;
@NotNull private final Set<GitLocalBranch> myLocalBranches;
@NotNull private final Set<GitRemoteBranch> myRemoteBranches;
@NotNull private final Set<GitBranchTrackInfo> myBranchTrackInfos;
public GitRepoInfo(@Nullable GitLocalBranch currentBranch, @Nullable String currentRevision, @NotNull Repository.State state,
@NotNull Collection<GitRemote> remotes, @NotNull Collection<GitLocalBranch> localBranches,
@@ -42,10 +44,10 @@ public class GitRepoInfo {
myCurrentBranch = currentBranch;
myCurrentRevision = currentRevision;
myState = state;
myRemotes = remotes;
myLocalBranches = localBranches;
myRemoteBranches = remoteBranches;
myBranchTrackInfos = branchTrackInfos;
myRemotes = new LinkedHashSet<GitRemote>(remotes);
myLocalBranches = new LinkedHashSet<GitLocalBranch>(localBranches);
myRemoteBranches = new LinkedHashSet<GitRemoteBranch>(remoteBranches);
myBranchTrackInfos = new LinkedHashSet<GitBranchTrackInfo>(branchTrackInfos);
}
@Nullable