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

org.loadui.testfx.utils.Matchers Maven / Gradle / Ivy

The newest version!
package org.loadui.testfx.utils;

import com.google.common.base.Predicate;
import org.hamcrest.Description;
import org.hamcrest.Matcher;
import org.hamcrest.TypeSafeMatcher;

public class Matchers {

    public static Matcher fromPredicate(final Predicate predicate)
    {
        return new TypeSafeMatcher() {
            @Override
            protected boolean matchesSafely(Object item) {
                try
                {
                    return predicate.apply(item);
                }
                catch (ClassCastException e)
                {
                    return false;
                }
            }

            @Override
            public void describeTo(Description description) {
            }
        };
    }
}