org.hamcrest.core.StringStartsWith Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of virtdata-lib-realer Show documentation
Show all versions of virtdata-lib-realer Show documentation
With inspiration from other libraries
The newest version!
/* Copyright (c) 2000-2006 hamcrest.org
*/
package org.hamcrest.core;
import org.hamcrest.Factory;
import org.hamcrest.Matcher;
/**
* Tests if the argument is a string that contains a substring.
*/
public class StringStartsWith extends SubstringMatcher {
public StringStartsWith(String substring) {
super(substring);
}
@Override
protected boolean evalSubstringOf(String s) {
return s.startsWith(substring);
}
@Override
protected String relationship() {
return "starting with";
}
/**
* Creates a matcher that matches if the examined {@link String} starts with the specified
* {@link String}.
*
* For example:
* assertThat("myStringOfNote", startsWith("my"))
*
* @param prefix
* the substring that the returned matcher will expect at the start of any examined string
*/
@Factory
public static Matcher startsWith(String prefix) {
return new StringStartsWith(prefix);
}
}