Skip to content

Commit d852892

Browse files
author
npryce
committed
Removed unchecked generics warnings
1 parent 2395d0b commit d852892

4 files changed

Lines changed: 12 additions & 13 deletions

File tree

‎src/library/org/hamcrest/collection/IsMapContaining.java‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
import org.hamcrest.Description;
44
import org.hamcrest.Factory;
55
import org.hamcrest.Matcher;
6-
import static org.hamcrest.core.IsAnything.anything;
6+
import org.hamcrest.core.IsAnything;
7+
78
import static org.hamcrest.core.IsEqual.eq;
89

910
import java.util.Map;
@@ -51,7 +52,7 @@ public static <K,V> Matcher<Map<K,V>> mapContaining(K key, V value) {
5152

5253
@Factory
5354
public static <K,V> Matcher<Map<K,V>> mapWithKey(Matcher<K> keyMatcher) {
54-
return mapContaining(keyMatcher, (Matcher<V>)anything());
55+
return mapContaining(keyMatcher, IsAnything.<V>anything());
5556
}
5657

5758
@Factory
@@ -61,12 +62,11 @@ public static <K,V> Matcher<Map<K,V>> mapWithKey(K key) {
6162

6263
@Factory
6364
public static <K,V> Matcher<Map<K,V>> mapWithValue(Matcher<V> valueMatcher) {
64-
return mapContaining((Matcher<K>)anything(), valueMatcher);
65+
return mapContaining(IsAnything.<K>anything(), valueMatcher);
6566
}
6667

6768
@Factory
6869
public static <K,V> Matcher<Map<K,V>> mapWithValue(V value) {
6970
return mapWithValue(eq(value));
7071
}
71-
7272
}

‎src/library/org/hamcrest/object/HasToString.java‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44
import org.hamcrest.Matcher;
55
import org.hamcrest.Factory;
66

7-
public class HasToString implements Matcher {
7+
public class HasToString<T> implements Matcher<T> {
88

99
private final Matcher<String> toStringMatcher;
1010

1111
public HasToString(Matcher<String> toStringMatcher) {
1212
this.toStringMatcher = toStringMatcher;
1313
}
1414

15-
public boolean match(Object item) {
15+
public boolean match(T item) {
1616
return toStringMatcher.match(item.toString());
1717
}
1818

@@ -21,10 +21,9 @@ public void describeTo(Description description) {
2121
toStringMatcher.describeTo(description);
2222
description.appendText(")");
2323
}
24-
24+
2525
@Factory
2626
public static <T> Matcher<T> asString(Matcher<String> toStringMatcher) {
27-
return new HasToString(toStringMatcher);
27+
return new HasToString<T>(toStringMatcher);
2828
}
29-
3029
}

‎src/unit-test/org/hamcrest/beans/HasPropertyTest.java‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@
22
*/
33
package org.hamcrest.beans;
44

5-
import org.hamcrest.AbstractMatcherTest;
6-
import org.hamcrest.beans.HasPropertyWithValueTest.BeanWithoutInfo;
7-
85
import static org.hamcrest.MatcherAssert.assertThat;
96
import static org.hamcrest.beans.HasProperty.hasProperty;
107
import static org.hamcrest.core.IsNot.not;
118

9+
import org.hamcrest.AbstractMatcherTest;
10+
1211
/**
1312
* @author Iain McGinniss
1413
* @author Nat Pryce

‎src/unit-test/org/hamcrest/core/IsNotTest.java‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
import static org.hamcrest.core.IsNot.not;
77

88
public class IsNotTest extends AbstractMatcherTest {
9-
public void testEvaluatesToTheTheLogicalNegationOfAnotherMatcher() {
9+
@SuppressWarnings("unchecked")
10+
public void testEvaluatesToTheTheLogicalNegationOfAnotherMatcher() {
1011
assertFalse(not(TRUE_MATCHER).match(ARGUMENT_IGNORED));
1112
assertTrue(not(FALSE_MATCHER).match(ARGUMENT_IGNORED));
1213
}

0 commit comments

Comments
 (0)