1 //////////////////////////////////////////////////////////////////////////////
2 // Clirr: compares two versions of a java library for binary compatibility
3 // Copyright (C) 2003 - 2004 Lars Kühne
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
20 package net.sf.clirr.event;
21
22
23 /***
24 * Describes an API change.
25 *
26 * @author Lars
27 */
28 public final class ApiDifference
29 {
30 private static final int HASHCODE_MAGIC = 29;
31
32 /*** human readable change report. */
33 private String report;
34
35 /*** severity of the change, as determined by clirr. */
36 private Severity severity;
37
38 /*** The fully qualified class name that is affected by the API change. */
39 private String affectedClass;
40
41 /***
42 * The method that is affected, if any.
43 * <p/>
44 * The content is the method name plus the fully qualified
45 * parameter types separated by comma and space and enclosed in
46 * brackets, e.g. "doStuff(java.lang.String, int)".
47 * <p/>
48 * This value is <code>null</code> if no single method is
49 * affected, i.e. if the
50 * api change affects a field or is global
51 * (like "class is now final").
52 */
53 private String affectedMethod;
54
55 /***
56 * The field that is affected, if any.
57 * <p/>
58 * The content is the field name, e.g. "someValue".
59 * Type information for the field is not available.
60 * <p/>
61 * This value is <code>null</code> if no single field is
62 * affected, i.e. if the
63 * api change affects a method or is global
64 * (like "class is now final").
65 */
66 private String affectedField;
67
68 /***
69 * Create a new API differnce representation.
70 *
71 * @param report a human readable string describing the change that was made.
72 * @param severity the severity in terms of binary API compatibility.
73 */
74 public ApiDifference(String report, Severity severity, String clazz, String method, String field)
75 {
76 this.report = report;
77 this.severity = severity;
78 this.affectedClass = clazz;
79 this.affectedField = field;
80 this.affectedMethod = method;
81 }
82
83 /***
84 * The Severity of the API difference. ERROR means that clients will
85 * definately break, WARNING means that clients may break, depending
86 * on how they use the library. See the eclipse paper for further
87 * explanation.
88 *
89 * @return the severity of the API difference.
90 */
91 public Severity getSeverity()
92 {
93 return severity;
94 }
95
96 /***
97 * Human readable api change description.
98 *
99 * @return a human readable description of this API difference.
100 */
101 public String getReport()
102 {
103 return report;
104 }
105
106 public String getAffectedClass()
107 {
108 return affectedClass;
109 }
110
111 public String getAffectedMethod()
112 {
113 return affectedMethod;
114 }
115
116 public String getAffectedField()
117 {
118 return affectedField;
119 }
120
121 /***
122 * {@inheritDoc}
123 */
124 public String toString()
125 {
126 return report + " (" + severity + ") - "
127 + getAffectedClass() + '[' + getAffectedField() + '/' + getAffectedMethod() + ']';
128 }
129
130 /***
131 * {@inheritDoc}
132 */
133 public boolean equals(Object o)
134 {
135 if (this == o)
136 {
137 return true;
138 }
139
140 if (!(o instanceof ApiDifference))
141 {
142 return false;
143 }
144
145 final ApiDifference other = (ApiDifference) o;
146
147 if (report != null ? !report.equals(other.report) : other.report != null)
148 {
149 return false;
150 }
151
152 if (severity != null ? !severity.equals(other.severity) : other.severity != null)
153 {
154 return false;
155 }
156
157 final String otherClass = other.affectedClass;
158 if (affectedClass != null ? !affectedClass.equals(otherClass) : otherClass != null)
159 {
160 return false;
161 }
162
163 final String otherMethod = other.affectedMethod;
164 if (affectedMethod != null ? !affectedMethod.equals(otherMethod) : otherMethod != null)
165 {
166 return false;
167 }
168
169 final String otherField = other.affectedField;
170 if (affectedField != null ? !affectedField.equals(otherField) : otherField != null)
171 {
172 return false;
173 }
174
175 return true;
176 }
177
178 public int hashCode()
179 {
180 int result;
181 result = report != null ? report.hashCode() : 0;
182 result = HASHCODE_MAGIC * result + (severity != null ? severity.hashCode() : 0);
183 result = HASHCODE_MAGIC * result + (affectedClass != null ? affectedClass.hashCode() : 0);
184 result = HASHCODE_MAGIC * result + (affectedMethod != null ? affectedMethod.hashCode() : 0);
185 result = HASHCODE_MAGIC * result + (affectedField != null ? affectedField.hashCode() : 0);
186 return result;
187 }
188 }
This page was automatically generated by Maven