File tree Expand file tree Collapse file tree
hamcrest-library/src/main/java/org/hamcrest/text Expand file tree Collapse file tree Original file line number Diff line number Diff line change 66
77import java .util .regex .Pattern ;
88
9- import org .hamcrest .BaseMatcher ;
109import org .hamcrest .Description ;
1110import org .hamcrest .Factory ;
1211import org .hamcrest .Matcher ;
12+ import org .hamcrest .TypeSafeMatcher ;
1313
1414/**
1515 * Matches blank Strings (and null).
1616 */
17- public final class IsBlankString extends BaseMatcher <String > {
17+ public final class IsBlankString extends TypeSafeMatcher <String > {
1818 private static final IsBlankString BLANK_INSTANCE = new IsBlankString ();
1919 @ SuppressWarnings ("unchecked" )
2020 private static final Matcher <String > NULL_OR_BLANK_INSTANCE = anyOf (nullValue (), BLANK_INSTANCE );
@@ -24,8 +24,8 @@ public final class IsBlankString extends BaseMatcher<String> {
2424 private IsBlankString () { }
2525
2626 @ Override
27- public boolean matches ( Object item ) {
28- return item != null && item instanceof String && REGEX_WHITESPACE .matcher (( String ) item ).matches ();
27+ public boolean matchesSafely ( String item ) {
28+ return REGEX_WHITESPACE .matcher (item ).matches ();
2929 }
3030
3131 @ Override
Original file line number Diff line number Diff line change 44import static org .hamcrest .core .AnyOf .anyOf ;
55import static org .hamcrest .core .IsNull .nullValue ;
66
7- import org .hamcrest .BaseMatcher ;
87import org .hamcrest .Description ;
98import org .hamcrest .Factory ;
109import org .hamcrest .Matcher ;
10+ import org .hamcrest .TypeSafeMatcher ;
1111
1212/**
1313 * Matches empty Strings (and null).
1414 */
15- public final class IsEmptyString extends BaseMatcher <String > {
15+ public final class IsEmptyString extends TypeSafeMatcher <String > {
1616 private static final IsEmptyString INSTANCE = new IsEmptyString ();
1717 @ SuppressWarnings ("unchecked" )
1818 private static final Matcher <String > NULL_OR_EMPTY_INSTANCE = anyOf (nullValue (), INSTANCE );
1919
2020 private IsEmptyString () { }
2121
2222 @ Override
23- public boolean matches ( Object item ) {
24- return item != null && item instanceof String && (( String ) item ) .equals ("" );
23+ public boolean matchesSafely ( String item ) {
24+ return item .equals ("" );
2525 }
2626
2727 @ Override
You can’t perform that action at this time.
0 commit comments