Package org.hamcrest.core
Class StringContains
- java.lang.Object
-
- org.hamcrest.BaseMatcher<T>
-
- org.hamcrest.TypeSafeMatcher<java.lang.String>
-
- org.hamcrest.core.SubstringMatcher
-
- org.hamcrest.core.StringContains
-
- All Implemented Interfaces:
Matcher<java.lang.String>,SelfDescribing
public class StringContains extends SubstringMatcher
Tests if the argument is a string that contains a specific substring.
-
-
Field Summary
-
Fields inherited from class org.hamcrest.core.SubstringMatcher
substring
-
-
Constructor Summary
Constructors Constructor Description StringContains(boolean ignoringCase, java.lang.String substring)StringContains(java.lang.String substring)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Matcher<java.lang.String>containsString(java.lang.String substring)Creates a matcher that matches if the examinedStringcontains the specifiedStringanywhere.static Matcher<java.lang.String>containsStringIgnoringCase(java.lang.String substring)Creates a matcher that matches if the examinedStringcontains the specifiedStringanywhere, ignoring case.protected booleanevalSubstringOf(java.lang.String s)-
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:
evalSubstringOfin classSubstringMatcher
-
containsString
public static Matcher<java.lang.String> containsString(java.lang.String substring)
Creates a matcher that matches if the examinedStringcontains the specifiedStringanywhere. For example:assertThat("myStringOfNote", containsString("ring"))- Parameters:
substring- the substring that the returned matcher will expect to find within any examined string- Returns:
- The matcher.
-
containsStringIgnoringCase
public static Matcher<java.lang.String> containsStringIgnoringCase(java.lang.String substring)
Creates a matcher that matches if the examinedStringcontains the specifiedStringanywhere, ignoring case. For example:assertThat("myStringOfNote", containsStringIgnoringCase("Ring"))- Parameters:
substring- the substring that the returned matcher will expect to find within any examined string- Returns:
- The matcher.
-
-