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

org.hamcrest.CustomMatcher Maven / Gradle / Ivy

Go to download

This is the core API of hamcrest matcher framework to be used by third-party framework providers. This includes the a foundation set of matcher implementations for common operations.

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

/**
 * Utility class for writing one off matchers.
 * For example:
 * 
 * Matcher<String> aNonEmptyString = new CustomMatcher<String>("a non empty string") {
 *   public boolean matches(Object object) {
 *     return ((object instanceof String) && !((String) object).isEmpty();
 *   }
 * };
 * 
*

* This class is designed for scenarios where an anonymous inner class * matcher makes sense. It should not be used by API designers implementing * matchers. * * @author Neil Dunn * @see CustomTypeSafeMatcher for a type safe variant of this class that you probably * want to use. * @param The type of object being matched. */ public abstract class CustomMatcher extends BaseMatcher { private final String fixedDescription; public CustomMatcher(String description) { if (description == null) { throw new IllegalArgumentException("Description should be non null!"); } this.fixedDescription = description; } public final void describeTo(Description description) { description.appendText(fixedDescription); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy