1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19 package org.apache.maven.scm;
20
21 import java.io.Serializable;
22
23 /**
24 * @author <a href="mailto:trygvis@inamo.no">Trygve Laugstøl</a>
25 *
26 */
27 public class ScmFile implements Comparable<ScmFile>, Serializable {
28 private static final long serialVersionUID = -9133015730693522690L;
29
30 private String path;
31
32 private ScmFileStatus status;
33
34 /**
35 * @param path The relative path of the file, should <b>never</b> start with any {@link java.io.File#separator}.
36 * @param status The file status
37 */
38 public ScmFile(String path, ScmFileStatus status) {
39 this.path = path;
40
41 this.status = status;
42 }
43
44 /**
45 * Returns the relative path of the file.
46 *
47 * @return the file path
48 */
49 public String getPath() {
50 return path;
51 }
52
53 /**
54 * @return The file status
55 */
56 public ScmFileStatus getStatus() {
57 return status;
58 }
59
60 // ----------------------------------------------------------------------
61 // Comparable Implementation
62 // ----------------------------------------------------------------------
63
64 /** {@inheritDoc} */
65 public int compareTo(ScmFile other) {
66 return other.getPath().compareTo(path);
67 }
68
69 // ----------------------------------------------------------------------
70 // Object overrides
71 // ----------------------------------------------------------------------
72
73 /** {@inheritDoc} */
74 public boolean equals(Object other) {
75 if (!(other instanceof ScmFile)) {
76 return false;
77 }
78
79 return ((ScmFile) other).getPath().equals(path);
80 }
81
82 /** {@inheritDoc} */
83 public int hashCode() {
84 return path.hashCode();
85 }
86
87 /** {@inheritDoc} */
88 public String toString() {
89 return "[" + path + ":" + status + "]";
90 }
91 }