javaslang.match.Matchs Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of javaslang Show documentation
Show all versions of javaslang Show documentation
Javaslang is a Java standard library extension built for Java 8 and above.
/** / \____ _ ______ _____ / \____ ____ _____
* / \__ \/ \ / \__ \ / __// \__ \ / \/ __ \ Javaslang
* _/ // _\ \ \/ / _\ \\_ \/ // _\ \ /\ \__/ / Copyright 2014-2015 Daniel Dietrich
* /___/ \_____/\____/\_____/____/\___\_____/_/ \_/____/ Licensed under the Apache License, Version 2.0
*/
package javaslang.match;
import java.util.function.*;
import javaslang.Functions.*;
/**
*
* Extension methods for {@link Match}.
*
* This class is not intended to be extended.
*/
public final class Matchs {
/**
* This class is not intended to be instantiated.
*/
private Matchs() {
throw new AssertionError(Matchs.class.getName() + " is not intended to be instantiated.");
}
/**
* Shortcut for {@code new Match.Builder().caze(function)}.
*
* @param return type of the matcher function
* @param function A function which is applied to a matched object.
* @return A Match of type T
*/
public static Match.Builder caze(λ1, R> function) {
return new Match.Builder().caze(function);
}
/**
* Shortcut for {@code new Match.Builder().caze(prototype, function)}.
*
* @param type of the prototype object
* @param return type of the matcher function
* @param prototype An object which matches by equality.
* @param function A function which is applied to a matched object.
* @return A Match of type T
*/
public static Match.Builder caze(T prototype, λ1 function) {
return new Match.Builder().caze(prototype, function);
}
public static Match.Builder caze(BooleanFunction function) {
return new Match.Builder().caze(function);
}
public static Match.Builder caze(ByteFunction function) {
return new Match.Builder().caze(function);
}
public static Match.Builder caze(CharFunction function) {
return new Match.Builder().caze(function);
}
public static Match.Builder caze(DoubleFunction function) {
return new Match.Builder().caze(function);
}
public static Match.Builder caze(FloatFunction function) {
return new Match.Builder().caze(function);
}
public static Match.Builder caze(IntFunction function) {
return new Match.Builder().caze(function);
}
public static Match.Builder caze(LongFunction function) {
return new Match.Builder().caze(function);
}
public static Match.Builder caze(ShortFunction function) {
return new Match.Builder().caze(function);
}
}