org.hamcrest.core.StringEndsWith Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of hamcrest Show documentation
Show all versions of hamcrest Show documentation
Core API and libraries of hamcrest matcher framework.
package org.hamcrest.core;
import org.hamcrest.Matcher;
/**
* Tests if the argument is a string that ends with a specific substring.
*/
public class StringEndsWith extends SubstringMatcher {
public StringEndsWith(boolean ignoringCase, String substring) { super("ending with", ignoringCase, substring); }
@Override
protected boolean evalSubstringOf(String s) {
return converted(s).endsWith(converted(substring));
}
/**
* Creates a matcher that matches if the examined {@link String} ends with the specified
* {@link String}.
* For example:
* assertThat("myStringOfNote", endsWith("Note"))
*
* @param suffix
* the substring that the returned matcher will expect at the end of any examined string
*/
public static Matcher endsWith(String suffix) {
return new StringEndsWith(false, suffix);
}
/**
* Creates a matcher that matches if the examined {@link String} ends with the specified
* {@link String}, ignoring case.
* For example:
* assertThat("myStringOfNote", endsWithIgnoringCase("note"))
*
* @param suffix
* the substring that the returned matcher will expect at the end of any examined string
*/
public static Matcher endsWithIgnoringCase(String suffix) {
return new StringEndsWith(true, suffix);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy