Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
Extension |
|
| 1.9090909090909092;1.909 |
1 | /* | |
2 | * $Id$ | |
3 | */ | |
4 | ||
5 | package org.apache.maven.model; | |
6 | ||
7 | //---------------------------------/ | |
8 | //- Imported classes and packages -/ | |
9 | //---------------------------------/ | |
10 | ||
11 | import java.util.Date; | |
12 | ||
13 | /** | |
14 | * Describes a build extension to utilise. | |
15 | * | |
16 | * @version $Revision$ $Date$ | |
17 | */ | |
18 | 0 | public class Extension implements java.io.Serializable { |
19 | ||
20 | ||
21 | //--------------------------/ | |
22 | //- Class/Member Variables -/ | |
23 | //--------------------------/ | |
24 | ||
25 | /** | |
26 | * The group ID of the extension's artifact. | |
27 | */ | |
28 | private String groupId; | |
29 | ||
30 | /** | |
31 | * The artifact ID of the extension. | |
32 | */ | |
33 | private String artifactId; | |
34 | ||
35 | /** | |
36 | * The version of the extension. | |
37 | */ | |
38 | private String version; | |
39 | ||
40 | ||
41 | //-----------/ | |
42 | //- Methods -/ | |
43 | //-----------/ | |
44 | ||
45 | /** | |
46 | * Get the artifact ID of the extension. | |
47 | * | |
48 | * @return String | |
49 | */ | |
50 | public String getArtifactId() | |
51 | { | |
52 | 0 | return this.artifactId; |
53 | } //-- String getArtifactId() | |
54 | ||
55 | /** | |
56 | * Get the group ID of the extension's artifact. | |
57 | * | |
58 | * @return String | |
59 | */ | |
60 | public String getGroupId() | |
61 | { | |
62 | 0 | return this.groupId; |
63 | } //-- String getGroupId() | |
64 | ||
65 | /** | |
66 | * Get the version of the extension. | |
67 | * | |
68 | * @return String | |
69 | */ | |
70 | public String getVersion() | |
71 | { | |
72 | 0 | return this.version; |
73 | } //-- String getVersion() | |
74 | ||
75 | /** | |
76 | * Set the artifact ID of the extension. | |
77 | * | |
78 | * @param artifactId | |
79 | */ | |
80 | public void setArtifactId( String artifactId ) | |
81 | { | |
82 | 0 | this.artifactId = artifactId; |
83 | 0 | } //-- void setArtifactId( String ) |
84 | ||
85 | /** | |
86 | * Set the group ID of the extension's artifact. | |
87 | * | |
88 | * @param groupId | |
89 | */ | |
90 | public void setGroupId( String groupId ) | |
91 | { | |
92 | 0 | this.groupId = groupId; |
93 | 0 | } //-- void setGroupId( String ) |
94 | ||
95 | /** | |
96 | * Set the version of the extension. | |
97 | * | |
98 | * @param version | |
99 | */ | |
100 | public void setVersion( String version ) | |
101 | { | |
102 | 0 | this.version = version; |
103 | 0 | } //-- void setVersion( String ) |
104 | ||
105 | ||
106 | ||
107 | /** | |
108 | * Gets the key of the extension. The key is used to merge extensions inherited from a parent with the extensions | |
109 | * of the current project. | |
110 | * | |
111 | * @return The key of the extension, i.e. <code>groupId:artifactId</code>. | |
112 | */ | |
113 | public String getKey() | |
114 | { | |
115 | 0 | return new StringBuffer( 128 ).append( getGroupId() ).append( ':' ).append( getArtifactId() ).toString(); |
116 | } | |
117 | ||
118 | /** | |
119 | * @see java.lang.Object#equals(java.lang.Object) | |
120 | */ | |
121 | public boolean equals( Object o ) | |
122 | { | |
123 | 0 | if ( this == o ) |
124 | { | |
125 | 0 | return true; |
126 | } | |
127 | ||
128 | 0 | if ( !( o instanceof Extension ) ) |
129 | { | |
130 | 0 | return false; |
131 | } | |
132 | ||
133 | 0 | Extension e = (Extension) o; |
134 | ||
135 | 0 | if ( !e.getArtifactId().equals( getArtifactId() ) ) |
136 | { | |
137 | 0 | return false; |
138 | } | |
139 | 0 | else if ( !e.getGroupId().equals( getGroupId() ) ) |
140 | { | |
141 | 0 | return false; |
142 | } | |
143 | 0 | else if ( e.getVersion() != null ? !e.getVersion().equals( getVersion() ) : getVersion() != null ) |
144 | { | |
145 | 0 | return false; |
146 | } | |
147 | 0 | return true; |
148 | } | |
149 | ||
150 | /** | |
151 | * @see java.lang.Object#hashCode() | |
152 | */ | |
153 | public int hashCode() | |
154 | { | |
155 | 0 | int result = 17; |
156 | 0 | result = 37 * result + ( getArtifactId() != null ? getArtifactId().hashCode() : 0 ); |
157 | 0 | result = 37 * result + ( getGroupId() != null ? getGroupId().hashCode() : 0 ); |
158 | 0 | result = 37 * result + ( getVersion() != null ? getVersion().hashCode() : 0 ); |
159 | 0 | return result; |
160 | } | |
161 | ||
162 | ||
163 | 0 | private String modelEncoding = "UTF-8"; |
164 | ||
165 | /** | |
166 | * Set an encoding used for reading/writing the model. | |
167 | * | |
168 | * @param modelEncoding the encoding used when reading/writing the model. | |
169 | */ | |
170 | public void setModelEncoding( String modelEncoding ) | |
171 | { | |
172 | 0 | this.modelEncoding = modelEncoding; |
173 | 0 | } |
174 | ||
175 | /** | |
176 | * @return the current encoding used when reading/writing this model. | |
177 | */ | |
178 | public String getModelEncoding() | |
179 | { | |
180 | 0 | return modelEncoding; |
181 | } | |
182 | } |