Created
June 24, 2016 15:22
-
-
Save josketres/2971079d0865010b2834f582f5a443e5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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