Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
package com.josketres.test.util;
import org.hamcrest.FeatureMatcher;
import org.hamcrest.Matcher;
import java.util.function.Function;
/**
* Utilities and syntactic sugar stuff for hamcrest.
*/
public class CaraHamcrestSugar {
private CaraHamcrestSugar() {
}
/**
* An easier way to create a FeatureMatcher.
*/
public static <T, U> Matcher<T> featureMatcher(Function<T, U> map, String featureName, Matcher<? super U> subMatcher) {
return new FeatureMatcher<T, U>(subMatcher, featureName, featureName) {
@Override
protected U featureValueOf(T o) {
return map.apply(o);
}
};
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.