1 /*
2 * Copyright 2006-2012 smartics, Kronseder & Reiner GmbH
3 *
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
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
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.
15 */
16 package de.smartics.maven.plugin.buildmetadata.scm.maven;
17
18 import java.io.Serializable;
19 import java.util.Date;
20
21 import de.smartics.maven.plugin.buildmetadata.scm.Revision;
22
23 /**
24 * Implementation for a simple revision string.
25 *
26 * @author <a href="mailto:robert.reiner@smartics.de">Robert Reiner</a>
27 * @version $Revision:591 $
28 */
29 public class StringRevision implements Revision, Serializable
30 {
31 // ********************************* Fields *********************************
32
33 // --- constants ------------------------------------------------------------
34
35 /**
36 * The class version identifier.
37 */
38 private static final long serialVersionUID = 1L;
39
40 // --- members --------------------------------------------------------------
41
42 /**
43 * The ID of the revision.
44 */
45 private final String id;
46
47 /**
48 * The revision date.
49 */
50 private final Date date;
51
52 // ****************************** Initializer *******************************
53
54 // ****************************** Constructors ******************************
55
56 /**
57 * Default constructor.
58 *
59 * @param id the ID of the revision.
60 * @param date the revision date.
61 */
62 public StringRevision(final String id, final Date date)
63 {
64 this.id = id;
65 this.date = new Date(date.getTime());
66 }
67
68 // ****************************** Inner Classes *****************************
69
70 // ********************************* Methods ********************************
71
72 // --- init -----------------------------------------------------------------
73
74 // --- get&set --------------------------------------------------------------
75
76 /**
77 * Returns the ID of the revision.
78 *
79 * @return the ID of the revision.
80 */
81 public final String getId()
82 {
83 return id;
84 }
85
86 /**
87 * Returns the revision date.
88 *
89 * @return the revision date.
90 */
91 public final Date getDate()
92 {
93 return new Date(date.getTime());
94 }
95
96 // --- business -------------------------------------------------------------
97
98 // --- object basics --------------------------------------------------------
99
100 /**
101 * {@inheritDoc}
102 */
103 // CHECKSTYLE:OFF
104 public String toString() // CHECKSTYLE:ON
105 {
106 return id + " at " + date;
107 }
108 }