1 /*
2 * Copyright 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.issue.config;
17
18 import org.apache.commons.lang.ObjectUtils;
19
20 /**
21 * Component information to associate to a product.
22 */
23 public final class Component
24 {
25 // ********************************* Fields *********************************
26
27 // --- constants ------------------------------------------------------------
28
29 // --- members --------------------------------------------------------------
30
31 /**
32 * The name of the component. This is the Maven submodule name.
33 */
34 private String name;
35
36 /**
37 * The description of the component. Should be the description from the sub
38 * modules POM. Not in the current version.
39 */
40 private String description;
41
42 // ****************************** Initializer *******************************
43
44 // ****************************** Constructors ******************************
45
46 /**
47 * Loader constructor.
48 */
49 public Component()
50 {
51 }
52
53 /**
54 * Default constructor.
55 *
56 * @param name the name of the component.
57 * @param description the description of the component.
58 */
59 public Component(final String name, final String description)
60 {
61 this.name = name;
62 this.description = description;
63 }
64
65 // ****************************** Inner Classes *****************************
66
67 // ********************************* Methods ********************************
68
69 // --- init -----------------------------------------------------------------
70
71 // --- get&set --------------------------------------------------------------
72
73 /**
74 * Returns the name of the component. This is the Maven submodule name.
75 *
76 * @return the name of the component.
77 */
78 public String getName()
79 {
80 return name;
81 }
82
83 /**
84 * Returns the description of the component. Should be the description from
85 * the sub modules POM. Not in the current version.
86 *
87 * @return the description of the component.
88 */
89 public String getDescription()
90 {
91 return description;
92 }
93
94 // --- business -------------------------------------------------------------
95
96 // --- object basics --------------------------------------------------------
97
98 /**
99 * Returns the hash code of the object.
100 *
101 * @return the hash code.
102 */
103 @Override
104 public int hashCode()
105 {
106 return ObjectUtils.hashCode(name);
107 }
108
109 /**
110 * Returns <code>true</code> if the given object is semantically equal to the
111 * given object, <code>false</code> otherwise.
112 *
113 * @param object the instance to compare to.
114 * @return <code>true</code> if the given object is semantically equal to the
115 * given object, <code>false</code> otherwise.
116 */
117 @Override
118 public boolean equals(final Object object)
119 {
120 if (this == object)
121 {
122 return true;
123 }
124 else if (object == null || getClass() != object.getClass())
125 {
126 return false;
127 }
128
129 final Component other = (Component) object;
130
131 return ObjectUtils.equals(name, other.name)
132 || ObjectUtils.equals(description, other.description);
133 }
134
135 /**
136 * {@inheritDoc}
137 *
138 * @see java.lang.Object#toString()
139 */
140 @Override
141 public String toString()
142 {
143 return name + ": " + description;
144 }
145 }