Package org.hamcrest.core
Class StringStartsWith
- java.lang.Object
-
- org.hamcrest.BaseMatcher<T>
-
- org.hamcrest.TypeSafeMatcher<java.lang.String>
-
- org.hamcrest.core.SubstringMatcher
-
- org.hamcrest.core.StringStartsWith
-
- All Implemented Interfaces:
Matcher<java.lang.String>
,SelfDescribing
public class StringStartsWith extends SubstringMatcher
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
Constructors Constructor Description StringStartsWith(boolean ignoringCase, java.lang.String substring)
StringStartsWith(java.lang.String substring)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected boolean
evalSubstringOf(java.lang.String s)
static Matcher<java.lang.String>
startsWith(java.lang.String prefix)
Creates a matcher that matches if the examinedString
starts with the specifiedString
.static Matcher<java.lang.String>
startsWithIgnoringCase(java.lang.String prefix)
Creates a matcher that matches if the examinedString
starts with the specifiedString
, ignoring case-
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
-
-
-
-
Method Detail
-
evalSubstringOf
protected boolean evalSubstringOf(java.lang.String s)
- Specified by:
evalSubstringOf
in classSubstringMatcher
-
startsWith
public static Matcher<java.lang.String> startsWith(java.lang.String prefix)
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
-
startsWithIgnoringCase
public static Matcher<java.lang.String> startsWithIgnoringCase(java.lang.String prefix)
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
-
-