Package org.hamcrest.core
Class StringEndsWith
java.lang.Object
org.hamcrest.BaseMatcher<String>
org.hamcrest.TypeSafeMatcher<String>
org.hamcrest.core.SubstringMatcher
org.hamcrest.core.StringEndsWith
- All Implemented Interfaces:
Matcher<String>
,SelfDescribing
Tests if the argument is a string that ends with a specific substring.
-
Field Summary
Fields inherited from class org.hamcrest.core.SubstringMatcher
substring
-
Constructor Summary
ConstructorDescriptionStringEndsWith
(boolean ignoringCase, String suffix) Constructor, best used withendsWith(String)
orendsWithIgnoringCase(String)
.StringEndsWith
(String suffix) Constructor, best used withendsWith(String)
. -
Method Summary
Modifier and TypeMethodDescriptionendsWithIgnoringCase
(String suffix) protected boolean
Checks if the input matches the specific substring.Methods inherited from class org.hamcrest.core.SubstringMatcher
converted, describeMismatchSafely, describeTo, matchesSafely
Methods inherited from class org.hamcrest.TypeSafeMatcher
describeMismatch, matches
Methods inherited from class org.hamcrest.BaseMatcher
_dont_implement_Matcher___instead_extend_BaseMatcher_, isNotNull, toString
-
Constructor Details
-
StringEndsWith
Constructor, best used withendsWith(String)
.- Parameters:
suffix
- the expected end of the string.
-
StringEndsWith
Constructor, best used withendsWith(String)
orendsWithIgnoringCase(String)
.- Parameters:
ignoringCase
- whether to ignore case when matchingsuffix
- the expected end of the string.
-
-
Method Details
-
evalSubstringOf
Description copied from class:SubstringMatcher
Checks if the input matches the specific substring.- Specified by:
evalSubstringOf
in classSubstringMatcher
- Parameters:
s
- the string to check- Returns:
- the result of the match
-
endsWith
Creates a matcher that matches if the examinedString
ends with the specifiedString
. For example:assertThat("myStringOfNote", endsWith("Note"))
- Parameters:
suffix
- the substring that the returned matcher will expect at the end of any examined string- Returns:
- The matcher.
-
endsWithIgnoringCase
Creates a matcher that matches if the examinedString
ends with the specifiedString
, ignoring case. For example:assertThat("myStringOfNote", endsWithIgnoringCase("note"))
- Parameters:
suffix
- the substring that the returned matcher will expect at the end of any examined string- Returns:
- The matcher.
-