Hybrid one-argument function that is both a Closure and a Function. @since 6.0.0
| 166 | * @since 6.0.0 |
| 167 | */ |
| 168 | public static class FunctionClosure<T, R> extends Closure<R> implements Function<T, R> { |
| 169 | @Serial private static final long serialVersionUID = 1L; |
| 170 | private final Function<T, R> delegate; |
| 171 | |
| 172 | FunctionClosure(Function<T, R> delegate) { |
| 173 | super(null, null); |
| 174 | this.delegate = delegate; |
| 175 | this.maximumNumberOfParameters = 1; |
| 176 | this.parameterTypes = new Class<?>[]{Object.class}; |
| 177 | } |
| 178 | |
| 179 | @Override |
| 180 | public R apply(T t) { |
| 181 | return delegate.apply(t); |
| 182 | } |
| 183 | |
| 184 | @Override |
| 185 | @SuppressWarnings("unchecked") |
| 186 | public R call(Object arg) { |
| 187 | return apply((T) arg); |
| 188 | } |
| 189 | |
| 190 | @Override |
| 191 | @SuppressWarnings("unchecked") |
| 192 | public R call(Object... args) { |
| 193 | return apply((T) args[0]); |
| 194 | } |
| 195 | } |
| 196 | |
| 197 | /** |
| 198 | * Hybrid one-argument function that is both a {@link Closure} and a |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…