Package org.hamcrest.core
Class StringStartsWith
java.lang.Object
org.hamcrest.BaseMatcher<String>
org.hamcrest.TypeSafeMatcher<String>
org.hamcrest.core.SubstringMatcher
org.hamcrest.core.StringStartsWith
- All Implemented Interfaces:
Matcher<String>
,SelfDescribing
Tests if the argument is a string that starts with a specific substring.
-
Field Summary
Fields inherited from class org.hamcrest.core.SubstringMatcher
substring
-
Constructor Summary
ConstructorDescriptionStringStartsWith
(boolean ignoringCase, String prefix) Constructor, best used withstartsWith(String)
orstartsWithIgnoringCase(String)
.StringStartsWith
(String prefix) Constructor, best used withstartsWith(String)
. -
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
Checks if the input matches the specific substring.startsWith
(String prefix) startsWithIgnoringCase
(String prefix) 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
-
StringStartsWith
Constructor, best used withstartsWith(String)
.- Parameters:
prefix
- the expected start of the string.
-
StringStartsWith
Constructor, best used withstartsWith(String)
orstartsWithIgnoringCase(String)
.- Parameters:
ignoringCase
- whether to ignore case when matchingprefix
- the expected start 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
-
startsWith
Creates a matcher that matches if the examined
For example:String
starts with the specifiedString
.assertThat("myStringOfNote", startsWith("my"))
- Parameters:
prefix
- the substring that the returned matcher will expect at the start of any examined string- Returns:
- The matcher.
-
startsWithIgnoringCase
Creates a matcher that matches if the examined
For example:String
starts with the specifiedString
, ignoring caseassertThat("myStringOfNote", startsWithIgnoringCase("My"))
- Parameters:
prefix
- the substring that the returned matcher will expect at the start of any examined string- Returns:
- The matcher.
-