| %line | %branch | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| nl.toolforge.karma.core.vc.DevelopmentLine |
|
|
| 1 | /* |
|
| 2 | Karma core - Core of the Karma application |
|
| 3 | Copyright (C) 2004 Toolforge <www.toolforge.nl> |
|
| 4 | ||
| 5 | This library is free software; you can redistribute it and/or |
|
| 6 | modify it under the terms of the GNU Lesser General Public |
|
| 7 | License as published by the Free Software Foundation; either |
|
| 8 | version 2.1 of the License, or (at your option) any later version. |
|
| 9 | ||
| 10 | This library is distributed in the hope that it will be useful, |
|
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
| 13 | Lesser General Public License for more details. |
|
| 14 | ||
| 15 | You should have received a copy of the GNU Lesser General Public |
|
| 16 | License along with this library; if not, write to the Free Software |
|
| 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
| 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 | 425 | 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 | 425 | public DevelopmentLine(String lineName) { |
| 44 | ||
| 45 | 425 | if (lineName == null || !lineName.matches(getPatternString())) { |
| 46 | 26 | throw new PatternSyntaxException("Pattern mismatch for version. Should match " + getPatternString(), lineName, -1); |
| 47 | } |
|
| 48 | 399 | this.lineName = lineName; |
| 49 | 399 | } |
| 50 | ||
| 51 | public String getName() { |
|
| 52 | ||
| 53 | 139 | if (lineName == null) { |
| 54 | 0 | throw new KarmaRuntimeException("Line name has not been set."); |
| 55 | } |
|
| 56 | 139 | return lineName; |
| 57 | } |
|
| 58 | ||
| 59 | public int hashCode() { |
|
| 60 | 0 | return lineName.hashCode(); |
| 61 | } |
|
| 62 | ||
| 63 | public String getPatternString() { |
|
| 64 | 260 | 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 | 52 | if (!(o instanceof DevelopmentLine)) { |
| 74 | 0 | return false; |
| 75 | } |
|
| 76 | 52 | return ((DevelopmentLine) o).lineName.equals(this.lineName); |
| 77 | } |
|
| 78 | ||
| 79 | } |
| This report is generated by jcoverage, Maven and Maven JCoverage Plugin. |