org.hamcrest.core
Class StringStartsWith

java.lang.Object
  extended by org.hamcrest.BaseMatcher<T>
      extended by org.hamcrest.TypeSafeMatcher<String>
          extended by org.hamcrest.core.SubstringMatcher
              extended by org.hamcrest.core.StringStartsWith
All Implemented Interfaces:
Matcher<String>, SelfDescribing

public class StringStartsWith
extends SubstringMatcher

Tests if the argument is a string that contains a substring.


Field Summary
 
Fields inherited from class org.hamcrest.core.SubstringMatcher
substring
 
Constructor Summary
StringStartsWith(boolean ignoringCase, String substring)
           
 
Method Summary
protected  boolean evalSubstringOf(String s)
           
static Matcher<String> startsWith(String prefix)
          Creates a matcher that matches if the examined String starts with the specified String.
static Matcher<String> startsWithIgnoringCase(String prefix)
          Creates a matcher that matches if the examined String starts with the specified String, ignoring case

For example:

 
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_, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

StringStartsWith

public StringStartsWith(boolean ignoringCase,
                        String substring)
Method Detail

evalSubstringOf

protected boolean evalSubstringOf(String s)
Specified by:
evalSubstringOf in class SubstringMatcher

startsWith

public static Matcher<String> startsWith(String prefix)
Creates a matcher that matches if the examined String starts with the specified String.

For example:

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<String> startsWithIgnoringCase(String prefix)
Creates a matcher that matches if the examined String starts with the specified String, ignoring case

For example:

assertThat("myStringOfNote", startsWith("my"))

Parameters:
prefix - the substring that the returned matcher will expect at the start of any examined string


Copyright © 2014. All rights reserved.