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 virtdata-lib-curves4 Show documentation
Show all versions of virtdata-lib-curves4 Show documentation
Statistical sampling library for use in virtualdataset libraries, based on apache commons math 4
/* 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 StringEndsWith extends SubstringMatcher {
public StringEndsWith(String substring) {
super(substring);
}
@Override
protected boolean evalSubstringOf(String s) {
return s.endsWith(substring);
}
@Override
protected String relationship() {
return "ending with";
}
/**
* 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
*/
@Factory
public static Matcher endsWith(String suffix) {
return new StringEndsWith(suffix);
}
}