forked from FabricMC/fabric
joiner -> invokerFactory
This commit is contained in:
parent
9dffeebaf1
commit
004281cdac
3 changed files with 13 additions and 13 deletions
|
@ -35,12 +35,12 @@ public final class EventFactory {
|
||||||
EventFactoryImpl.invalidate();
|
EventFactoryImpl.invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T> Event<T> createArrayBacked(Class<T> type, Function<T[], T> joiner) {
|
public static <T> Event<T> createArrayBacked(Class<T> type, Function<T[], T> invokerFactory) {
|
||||||
return EventFactoryImpl.createArrayBacked(type, joiner);
|
return EventFactoryImpl.createArrayBacked(type, invokerFactory);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T> Event<T> createArrayBacked(Class<T> type, T emptyInvoker, Function<T[], T> joiner) {
|
public static <T> Event<T> createArrayBacked(Class<T> type, T emptyInvoker, Function<T[], T> invokerFactory) {
|
||||||
return EventFactoryImpl.createArrayBacked(type, emptyInvoker, joiner);
|
return EventFactoryImpl.createArrayBacked(type, emptyInvoker, invokerFactory);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getHandlerName(Object event) {
|
public static String getHandlerName(Object event) {
|
||||||
|
|
|
@ -24,14 +24,14 @@ import java.util.function.Function;
|
||||||
|
|
||||||
class ArrayBackedEvent<T> extends Event<T> {
|
class ArrayBackedEvent<T> extends Event<T> {
|
||||||
private final Class<T> type;
|
private final Class<T> type;
|
||||||
private final Function<T[], T> joiner;
|
private final Function<T[], T> invokerFactory;
|
||||||
private final T dummyInvoker;
|
private final T dummyInvoker;
|
||||||
private T[] handlers;
|
private T[] handlers;
|
||||||
|
|
||||||
ArrayBackedEvent(Class<T> type, T dummyInvoker, Function<T[], T> joiner) {
|
ArrayBackedEvent(Class<T> type, T dummyInvoker, Function<T[], T> invokerFactory) {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.dummyInvoker = dummyInvoker;
|
this.dummyInvoker = dummyInvoker;
|
||||||
this.joiner = joiner;
|
this.invokerFactory = invokerFactory;
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,12 +41,12 @@ class ArrayBackedEvent<T> extends Event<T> {
|
||||||
invoker = dummyInvoker;
|
invoker = dummyInvoker;
|
||||||
} else {
|
} else {
|
||||||
//noinspection unchecked
|
//noinspection unchecked
|
||||||
invoker = joiner.apply((T[]) Array.newInstance(type, 0));
|
invoker = invokerFactory.apply((T[]) Array.newInstance(type, 0));
|
||||||
}
|
}
|
||||||
} else if (handlers.length == 1) {
|
} else if (handlers.length == 1) {
|
||||||
invoker = handlers[0];
|
invoker = handlers[0];
|
||||||
} else {
|
} else {
|
||||||
invoker = joiner.apply(handlers);
|
invoker = invokerFactory.apply(handlers);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,12 +37,12 @@ public final class EventFactoryImpl {
|
||||||
ARRAY_BACKED_EVENTS.forEach(ArrayBackedEvent::update);
|
ARRAY_BACKED_EVENTS.forEach(ArrayBackedEvent::update);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T> Event<T> createArrayBacked(Class<T> type, Function<T[], T> joiner) {
|
public static <T> Event<T> createArrayBacked(Class<T> type, Function<T[], T> invokerFactory) {
|
||||||
return createArrayBacked(type, null /* buildEmptyInvoker(type, joiner) */, joiner);
|
return createArrayBacked(type, null /* buildEmptyInvoker(type, invokerFactory) */, invokerFactory);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T> Event<T> createArrayBacked(Class<T> type, T emptyInvoker, Function<T[], T> joiner) {
|
public static <T> Event<T> createArrayBacked(Class<T> type, T emptyInvoker, Function<T[], T> invokerFactory) {
|
||||||
ArrayBackedEvent<T> event = new ArrayBackedEvent<>(type, emptyInvoker, joiner);
|
ArrayBackedEvent<T> event = new ArrayBackedEvent<>(type, emptyInvoker, invokerFactory);
|
||||||
ARRAY_BACKED_EVENTS.add(event);
|
ARRAY_BACKED_EVENTS.add(event);
|
||||||
return event;
|
return event;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue