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

io.github.olib963.javatest.matchers.Matcher Maven / Gradle / Ivy

There is a newer version: 0.2.0
Show newest version
package io.github.olib963.javatest.matchers;

import io.github.olib963.javatest.Assertion;
import io.github.olib963.javatest.matchers.internal.MatcherAssertion;
import io.github.olib963.javatest.matchers.internal.PredicateMatcher;

import java.util.function.Function;
import java.util.function.Predicate;

public interface Matcher {
    MatchResult matches(A value);
    String describeExpected();

    static  Matcher fromFunctions(Predicate predicate, String expected) {
        return PredicateMatcher.of(predicate, expected);
    }

    static  Matcher fromFunctions(Predicate predicate, String expected, Function mismatchDescriptionFunction) {
        return PredicateMatcher.of(predicate, expected, mismatchDescriptionFunction);
    }

    static  Assertion that(A value, Matcher matcher) {
        return new MatcherAssertion<>(value, matcher);
    }

    static  Matcher isEqualTo(A expected) {
        return PredicateMatcher.isEqualTo(expected);
    }

    static  Matcher hasType(Class expectedClass) {
        return PredicateMatcher.hasType(expectedClass);
    }

    static  Matcher isTheSameInstanceAs(A instance) {
        return PredicateMatcher.isTheSameInstanceAs(instance);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy