1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package nl.toolforge.karma.core.vc;
20
21 import nl.toolforge.karma.core.KarmaRuntimeException;
22
23 import java.util.regex.PatternSyntaxException;
24
25 /***
26 * A development line is a separate line of development for a module, generally implemented by a version control
27 * system through a branch.
28 *
29 * @author D.A. Smedes
30 * @version $Id: DevelopmentLine.java,v 1.8 2004/08/29 18:00:38 hippe Exp $
31 */
32 public class DevelopmentLine {
33
34 public static final String DEVELOPMENT_LINE_PATTERN_STRING = "[A-Za-z-]+[A-Z0-9a-z-]*";
35
36 private String lineName = null;
37
38 /***
39 * Constructor for a development line. <code>lineName</code> should match {@link DEVELOPMENT_LINE_PATTERN_STRING}.
40 *
41 * @param lineName The name for a development line
42 */
43 public DevelopmentLine(String lineName) {
44
45 if (lineName == null || !lineName.matches(getPatternString())) {
46 throw new PatternSyntaxException("Pattern mismatch for version. Should match " + getPatternString(), lineName, -1);
47 }
48 this.lineName = lineName;
49 }
50
51 public String getName() {
52
53 if (lineName == null) {
54 throw new KarmaRuntimeException("Line name has not been set.");
55 }
56 return lineName;
57 }
58
59 public int hashCode() {
60 return lineName.hashCode();
61 }
62
63 public String getPatternString() {
64 return DEVELOPMENT_LINE_PATTERN_STRING;
65 }
66
67 /***
68 * Compares two DevelopmentLine instance for equality. Two instances are equal when their names are the same.
69 *
70 * @param o Object (of type DevelopmentLine)
71 */
72 public boolean equals(Object o) {
73 if (!(o instanceof DevelopmentLine)) {
74 return false;
75 }
76 return ((DevelopmentLine) o).lineName.equals(this.lineName);
77 }
78
79 }