Skip to content
This repository was archived by the owner on Jan 20, 2023. It is now read-only.

Commit d1b965c

Browse files
committed
一応共通インターフェースを整備
1 parent 62ab2df commit d1b965c

File tree

4 files changed

+17
-3
lines changed

4 files changed

+17
-3
lines changed

src/main/java/com/mapk/fastkfunction/spreadwrapper/ForConstructor.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@
55
import java.lang.reflect.Constructor;
66
import java.lang.reflect.InvocationTargetException;
77

8-
public class ForConstructor<T> {
8+
public class ForConstructor<T> implements SpreadWrapper<T> {
99
private final Constructor<T> constructor;
1010

1111
public ForConstructor(@NotNull Constructor<T> constructor) {
1212
this.constructor = constructor;
1313
}
1414

15+
@Override
1516
public T call(Object[] args) throws IllegalAccessException, InvocationTargetException, InstantiationException {
1617
return constructor.newInstance(args);
1718
}

src/main/java/com/mapk/fastkfunction/spreadwrapper/ForKFunction.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@
33
import kotlin.reflect.KFunction;
44
import org.jetbrains.annotations.NotNull;
55

6-
public class ForKFunction<T> {
6+
public class ForKFunction<T> implements SpreadWrapper<T> {
77
private final KFunction<T> kFunction;
88

99
public ForKFunction(@NotNull KFunction<T> kFunction) {
1010
this.kFunction = kFunction;
1111
}
1212

13+
@Override
1314
public T call(Object[] args) {
1415
return kFunction.call(args);
1516
}

src/main/java/com/mapk/fastkfunction/spreadwrapper/ForMethod.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import java.lang.reflect.InvocationTargetException;
77
import java.lang.reflect.Method;
88

9-
public class ForMethod {
9+
public class ForMethod implements SpreadWrapper<Object> {
1010
private final Method method;
1111
private final Object instance;
1212

@@ -15,6 +15,7 @@ public ForMethod(@NotNull Method method, @Nullable Object instance) {
1515
this.instance = instance;
1616
}
1717

18+
@Override
1819
public Object call(Object[] args) throws InvocationTargetException, IllegalAccessException {
1920
return method.invoke(instance, args);
2021
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package com.mapk.fastkfunction.spreadwrapper;
2+
3+
import java.lang.reflect.InvocationTargetException;
4+
5+
/**
6+
* Wrapper to avoid using Kotlin's heavy spread operator.
7+
* @param <T> return type
8+
*/
9+
public interface SpreadWrapper<T> {
10+
T call(Object[] args) throws InvocationTargetException, IllegalAccessException, InstantiationException;
11+
}

0 commit comments

Comments
 (0)