Java 类org.eclipse.xtext.xbase.lib.Functions.Function4 实例源码

项目:xtext-lib    文件:FunctionExtensions.java   
/**
 * Curries a function that takes four arguments.
 * 
 * @param function
 *            the original function. May not be <code>null</code>.
 * @param argument
 *            the fixed first argument of {@code function}.
 * @return a function that takes three arguments. Never <code>null</code>.
 */
@Pure
public static <P1, P2, P3, P4, RESULT> Function3<P2, P3, P4, RESULT> curry(
        final Function4<? super P1, ? super P2, ? super P3, ? super P4, ? extends RESULT> function, final P1 argument) {
    if (function == null)
        throw new NullPointerException("function");
    return new Function3<P2, P3, P4, RESULT>() {
        @Override
        public RESULT apply(P2 p2, P3 p3, P4 p4) {
            return function.apply(argument, p2, p3, p4);
        }
    };
}
项目:xtext-lib    文件:FunctionExtensions.java   
/**
 * Curries a function that takes five arguments.
 * 
 * @param function
 *            the original function. May not be <code>null</code>.
 * @param argument
 *            the fixed first argument of {@code function}.
 * @return a function that takes four arguments. Never <code>null</code>.
 */
@Pure
public static <P1, P2, P3, P4, P5, RESULT> Function4<P2, P3, P4, P5, RESULT> curry(
        final Function5<? super P1, ? super P2, ? super P3, ? super P4, ? super P5, ? extends RESULT> function, final P1 argument) {
    if (function == null)
        throw new NullPointerException("function");
    return new Function4<P2, P3, P4, P5, RESULT>() {
        @Override
        public RESULT apply(P2 p2, P3 p3, P4 p4, P5 p5) {
            return function.apply(argument, p2, p3, p4, p5);
        }
    };
}
项目:Util    文件:SafeCallExtension.java   
/**
 * Calls some code safely.
 * Never throws an Exception.
 * @return
 * @return onError; if the code fails, otherwise the return value of call().
 */
public static <R, E1, E2, E3, E4> R attempt(
        final Function4<E1, E2, E3, E4, R> code, final E1 p1, final E2 p2,
        final E3 p3, final E4 p4, final R onError) {
    try {
        return code.apply(p1, p2, p3, p4);
    } catch (final Throwable t) {
        LOG.log(Level.SEVERE, t.getMessage(), t);
        return onError;
    }
}
项目:Util    文件:SafeCallExtension.java   
/**
 * Calls some code safely.
 * Never throws an Exception.
 * @return
 * @return null if the code fails, otherwise the return value of call().
 */
@Inline("com.blockwithme.util.xtend.SafeCallExtension.attempt($1, $2, $3, $4, null)")
public static <R, E1, E2, E3, E4> R attempt(
        final Function4<E1, E2, E3, E4, R> code, final E1 p1, final E2 p2,
        final E3 p3, final E4 p4) {
    return attempt(code, p1, p2, p3, p4, null);
}