All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.hamcrest.text.SubstringMatcher Maven / Gradle / Ivy

Go to download

A self-contained hamcrest jar containing all of the sub-modules in a single artifact.

There is a newer version: 1.3
Show newest version
package org.hamcrest.text;

import org.hamcrest.Description;
import org.hamcrest.TypeSafeMatcher;

public abstract class SubstringMatcher extends TypeSafeMatcher {

    // TODO: Replace String with CharSequence to allow for easy interopability between
    //       String, StringBuffer, StringBuilder, CharBuffer, etc (joe).

    protected final String substring;

    protected SubstringMatcher(final String substring) {
        this.substring = substring;
    }

    public boolean matchesSafely(String item) {
        return evalSubstringOf(item);
    }

    public void describeTo(Description description) {
        description.appendText("a string ")
                .appendText(relationship())
                .appendText(" ")
                .appendValue(substring);
    }

    protected abstract boolean evalSubstringOf(String string);

    protected abstract String relationship();
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy