Skip to content

Commit 31faeb3

Browse files
author
npryce
committed
Added constructor to explicitly pass expected type to TypeSafeMatcher
Cleaned up some warnings
1 parent 4cfdc63 commit 31faeb3

9 files changed

Lines changed: 17 additions & 8 deletions

File tree

‎.classpath‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<classpath>
33
<classpathentry kind="src" path="src/api"/>
4+
<classpathentry kind="src" path="src/generator"/>
45
<classpathentry kind="src" path="src/examples"/>
56
<classpathentry kind="src" path="src/integration"/>
67
<classpathentry kind="src" path="src/library"/>

‎src/api/org/hamcrest/Matcher.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* A matcher over acceptable values.
77
* A matcher is able to describe itself to give feedback when it fails.
88
*/
9-
@SuppressWarnings({"UnusedDeclaration"})
9+
@SuppressWarnings("unused")
1010
public interface Matcher<T> extends SelfDescribing {
1111

1212
/**

‎src/library/org/hamcrest/TypeSafeMatcher.java‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ protected TypeSafeMatcher() {
3030
throw new Error("Cannot determine correct type for matchesSafely() method.");
3131
}
3232
}
33+
34+
protected TypeSafeMatcher(Class<T> expectedType) {
35+
this.expectedType = expectedType;
36+
}
3337

3438
/**
3539
* Method made final to prevent accidental override.

‎src/library/org/hamcrest/number/OrderingComparisons.java‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,14 @@
88
import org.hamcrest.Factory;
99
import org.hamcrest.Matcher;
1010

11+
@SuppressWarnings("unchecked")
1112
public class OrderingComparisons {
1213
@Factory
1314
public static <T extends Comparable<T>> Matcher<T> greaterThan(T value) {
1415
return new IsGreaterThan<T>(value);
1516
}
1617

17-
@Factory
18+
@Factory
1819
public static <T extends Comparable<T>> Matcher<T> greaterThanOrEqualTo(T value) {
1920
return describedAs("a value greater than or equal to %0",
2021
or(greaterThan(value), eq(value)),

‎src/unit-test/org/hamcrest/collection/IsArrayTest.java‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@
66
import org.hamcrest.AbstractMatcherTest;
77
import org.hamcrest.Matcher;
88

9+
@SuppressWarnings("unchecked")
910
public class IsArrayTest extends AbstractMatcherTest {
1011

11-
protected Matcher<?> createMatcher() {
12+
protected Matcher<?> createMatcher() {
1213
return array(eq("irrelevant"));
1314
}
1415

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@
1010
import static org.hamcrest.MatcherAssert.assertThat;
1111

1212

13+
@SuppressWarnings("unchecked")
1314
public class AndTest extends AbstractMatcherTest {
1415

15-
protected Matcher<?> createMatcher() {
16+
protected Matcher<?> createMatcher() {
1617
return and(eq("irrelevant"), eq("irrelevant"));
1718
}
1819

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@
99
import static org.hamcrest.core.IsNot.not;
1010
import static org.hamcrest.core.Or.or;
1111

12+
@SuppressWarnings("unchecked")
1213
public class OrTest extends AbstractMatcherTest {
1314

14-
protected Matcher<?> createMatcher() {
15+
protected Matcher<?> createMatcher() {
1516
return or(eq("irrelevant"));
1617
}
1718

‎src/unit-test/org/hamcrest/generator/HamcrestFactoryWriterTest.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
package org.hamcrest.generator;
22

3-
import junit.framework.TestCase;
4-
53
import java.io.IOException;
64
import java.io.StringWriter;
75

6+
import junit.framework.TestCase;
7+
88
public class HamcrestFactoryWriterTest extends TestCase {
99

1010
private FactoryWriter factoryWriter;

‎src/unit-test/org/hamcrest/generator/ReflectiveFactoryReaderTest.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import java.util.Map;
1313
import java.util.Set;
1414

15-
@SuppressWarnings({"UnusedDeclaration"})
15+
@SuppressWarnings("unused")
1616
public class ReflectiveFactoryReaderTest extends TestCase {
1717

1818
public static class SimpleSetOfMatchers {

0 commit comments

Comments
 (0)