Skip to content

Commit 1f4b33c

Browse files
committed
Fix compiler warnings in Constants/ConstantsTests
1 parent 6ffb043 commit 1f4b33c

File tree

2 files changed

+14
-13
lines changed

2 files changed

+14
-13
lines changed

spring-core/src/main/java/org/springframework/core/Constants.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public class Constants {
5858
* @param clazz the class to analyze
5959
* @throws IllegalArgumentException if the supplied <code>clazz</code> is <code>null</code>
6060
*/
61-
public Constants(Class clazz) {
61+
public Constants(Class<?> clazz) {
6262
Assert.notNull(clazz);
6363
this.className = clazz.getName();
6464
Field[] fields = clazz.getFields();
@@ -189,7 +189,7 @@ public Set<String> getNamesForProperty(String propertyName) {
189189
* @param nameSuffix suffix of the constant names to search (may be <code>null</code>)
190190
* @return the set of constant names
191191
*/
192-
public Set getNamesForSuffix(String nameSuffix) {
192+
public Set<String> getNamesForSuffix(String nameSuffix) {
193193
String suffixToUse = (nameSuffix != null ? nameSuffix.trim().toUpperCase(Locale.ENGLISH) : "");
194194
Set<String> names = new HashSet<String>();
195195
for (String code : this.fieldCache.keySet()) {

spring-core/src/test/java/org/springframework/core/ConstantsTests.java

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public void testConstants() {
5757
public void testGetNames() {
5858
Constants c = new Constants(A.class);
5959

60-
Set names = c.getNames("");
60+
Set<?> names = c.getNames("");
6161
assertEquals(c.getSize(), names.size());
6262
assertTrue(names.contains("DOG"));
6363
assertTrue(names.contains("CAT"));
@@ -75,7 +75,7 @@ public void testGetNames() {
7575
public void testGetValues() {
7676
Constants c = new Constants(A.class);
7777

78-
Set values = c.getValues("");
78+
Set<?> values = c.getValues("");
7979
assertEquals(7, values.size());
8080
assertTrue(values.contains(new Integer(0)));
8181
assertTrue(values.contains(new Integer(66)));
@@ -102,7 +102,7 @@ public void testGetValuesInTurkey() {
102102
try {
103103
Constants c = new Constants(A.class);
104104

105-
Set values = c.getValues("");
105+
Set<?> values = c.getValues("");
106106
assertEquals(7, values.size());
107107
assertTrue(values.contains(new Integer(0)));
108108
assertTrue(values.contains(new Integer(66)));
@@ -130,12 +130,12 @@ public void testGetValuesInTurkey() {
130130
public void testSuffixAccess() {
131131
Constants c = new Constants(A.class);
132132

133-
Set names = c.getNamesForSuffix("_PROPERTY");
133+
Set<?> names = c.getNamesForSuffix("_PROPERTY");
134134
assertEquals(2, names.size());
135135
assertTrue(names.contains("NO_PROPERTY"));
136136
assertTrue(names.contains("YES_PROPERTY"));
137137

138-
Set values = c.getValuesForSuffix("_PROPERTY");
138+
Set<?> values = c.getValuesForSuffix("_PROPERTY");
139139
assertEquals(2, values.size());
140140
assertTrue(values.contains(new Integer(3)));
141141
assertTrue(values.contains(new Integer(4)));
@@ -210,26 +210,26 @@ public void testToCode() {
210210

211211
public void testGetValuesWithNullPrefix() throws Exception {
212212
Constants c = new Constants(A.class);
213-
Set values = c.getValues(null);
213+
Set<?> values = c.getValues(null);
214214
assertEquals("Must have returned *all* public static final values", 7, values.size());
215215
}
216216

217217
public void testGetValuesWithEmptyStringPrefix() throws Exception {
218218
Constants c = new Constants(A.class);
219-
Set values = c.getValues("");
219+
Set<Object> values = c.getValues("");
220220
assertEquals("Must have returned *all* public static final values", 7, values.size());
221221
}
222222

223223
public void testGetValuesWithWhitespacedStringPrefix() throws Exception {
224224
Constants c = new Constants(A.class);
225-
Set values = c.getValues(" ");
225+
Set<?> values = c.getValues(" ");
226226
assertEquals("Must have returned *all* public static final values", 7, values.size());
227227
}
228228

229229
public void testWithClassThatExposesNoConstants() throws Exception {
230230
Constants c = new Constants(NoConstants.class);
231231
assertEquals(0, c.getSize());
232-
final Set values = c.getValues("");
232+
final Set<?> values = c.getValues("");
233233
assertNotNull(values);
234234
assertEquals(0, values.size());
235235
}
@@ -245,10 +245,11 @@ public void testCtorWithNullClass() throws Exception {
245245

246246
private static final class NoConstants {
247247
}
248-
249248

249+
250+
@SuppressWarnings("unused")
250251
private static final class A {
251-
252+
252253
public static final int DOG = 0;
253254
public static final int CAT = 66;
254255
public static final String S1 = "";

0 commit comments

Comments
 (0)