use of ru.curs.celesta.event.TriggerType in project celesta by CourseOrchestra.
the class CursorGenerator method buildTriggerRegistration.
private static List<MethodSpec> buildTriggerRegistration(TypeName selfTypeName) {
ParameterSpec celestaParam = ParameterSpec.builder(ICelesta.class, "celesta").build();
ParameterSpec consumerParam = ParameterSpec.builder(ParameterizedTypeName.get(ClassName.get(Consumer.class), WildcardTypeName.supertypeOf(selfTypeName)), "cursorConsumer").build();
return TRIGGER_REGISTRATION_METHOD_TO_TRIGGER_TYPE.entrySet().stream().map(e -> {
String methodName = e.getKey();
String triggerType = e.getValue();
return MethodSpec.methodBuilder(methodName).addModifiers(Modifier.PUBLIC, Modifier.STATIC).addParameter(celestaParam).addParameter(consumerParam).addStatement("$N.getTriggerDispatcher().registerTrigger($T.$N, $T.class, $N)", celestaParam.name, TriggerType.class, triggerType, selfTypeName, consumerParam.name).build();
}).collect(Collectors.toList());
}
Aggregations