IDEA-27603 (Indicate which branch is being worked on)
[fedora-idea.git] / platform / vcs-impl / src / com / intellij / openapi / vcs / changes / FilePathUnderVcs.java
blob83d31d93a23f4c3b12f1e08d5db72b2be23c73cb
1 /*
2 * Copyright 2000-2009 JetBrains s.r.o.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package com.intellij.openapi.vcs.changes;
18 import com.intellij.openapi.util.Comparing;
19 import com.intellij.openapi.vcs.AbstractVcs;
20 import com.intellij.openapi.vcs.FilePath;
21 import com.intellij.openapi.vcs.FilePathImpl;
22 import com.intellij.openapi.vcs.VcsRoot;
24 public class FilePathUnderVcs {
25 private final FilePath myPath;
26 private final AbstractVcs myVcs;
28 public FilePathUnderVcs(final FilePath path, final AbstractVcs vcs) {
29 myPath = path;
30 myVcs = vcs;
33 FilePathUnderVcs(final VcsRoot root) {
34 myPath = new FilePathImpl(root.path);
35 myVcs = root.vcs;
38 public FilePath getPath() {
39 return myPath;
42 public AbstractVcs getVcs() {
43 return myVcs;
46 @Override
47 public boolean equals(Object o) {
48 if (this == o) return true;
49 if (o == null || getClass() != o.getClass()) return false;
51 FilePathUnderVcs that = (FilePathUnderVcs)o;
53 if (myPath != null ? !myPath.equals(that.myPath) : that.myPath != null) return false;
54 if (myVcs != null ? ! Comparing.equal(myVcs.getName(), that.myVcs.getName()) : that.myVcs != null) return false;
56 return true;
59 @Override
60 public int hashCode() {
61 int result = myPath != null ? myPath.hashCode() : 0;
62 result = 31 * result + (myVcs != null ? myVcs.getName().hashCode() : 0);
63 return result;