
com.jfinal.kit.Func Maven / Gradle / Ivy
/**
* Copyright (c) 2011-2021, James Zhan 詹波 ([email protected]).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.jfinal.kit;
/**
* lambda 函数工具箱,主要用来解决 JDK 函数接口参数过少的问题,同时还降低了学习成本
*
* JDK java.util.function 包里面的函数接口有如下缺点:
* 1:设计繁琐,相比动态语言的闭包在理解和学习成本上要高
* 2:函数支持的参数过少,超过两个参数时就没法使用了
* 3:基于 java 接口的闭包实现方案,转移了用户对于函数本身这个核心要点的关注,
* 接口名、方法名带来了噪声干扰
*/
public interface Func {
/**
* 0 参 0 返回函数
*/
@FunctionalInterface
public interface F00 {
void call();
}
/**
* 1 参 0 返回函数
*/
@FunctionalInterface
public interface F10 {
void call(T t);
}
/**
* 2 参 0 返回函数
*/
@FunctionalInterface
public interface F20 {
void call(T t, U u);
}
/**
* 3 参 0 返回函数
*/
@FunctionalInterface
public interface F30 {
void call(T t, U u, V v);
}
/**
* 4 参 0 返回函数
*/
@FunctionalInterface
public interface F40 {
void call(T t, U u, V v, W w);
}
/**
* 5 参 0 返回函数
*/
@FunctionalInterface
public interface F50 {
void call(T t, U u, V v, W w, X x);
}
/**
* 6 参 0 返回函数
*/
@FunctionalInterface
public interface F60 {
void call(T t, U u, V v, W w, X x, Y y);
}
/**
* 7 参 0 返回函数
*/
@FunctionalInterface
public interface F70 {
void call(T t, U u, V v, W w, X x, Y y, Z z);
}
// ---------------------------------------------
/**
* 0 参 1 返回函数
*/
@FunctionalInterface
public interface F01 {
R call();
}
/**
* 1 参 1 返回函数
*/
@FunctionalInterface
public interface F11 {
R call(T t);
}
/**
* 2 参 1 返回函数
*/
@FunctionalInterface
public interface F21 {
R call(T t, U u);
}
/**
* 3 参 1 返回函数
*/
@FunctionalInterface
public interface F31 {
R call(T t, U u, V v);
}
/**
* 4 参 1 返回函数
*/
@FunctionalInterface
public interface F41 {
R call(T t, U u, V v, W w);
}
/**
* 5 参 1 返回函数
*/
@FunctionalInterface
public interface F51 {
R call(T t, U u, V v, W w, X x);
}
/**
* 6 参 1 返回函数
*/
@FunctionalInterface
public interface F61 {
R call(T t, U u, V v, W w, X x, Y y);
}
/**
* 7 参 1 返回函数
*/
@FunctionalInterface
public interface F71 {
R call(T t, U u, V v, W w, X x, Y y, Z z);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy