class ValidateEventListener implements EventListener, Ordered {

    @Override
    public String getId() {
        return "validate-listener";
    }

    @Override
    public String getName() {
        return "验证器监听器";
    }

    @Override

    public void onEvent(EventType type, EventContext context) {<FILL_FUNCTION_BODY>}

    @SuppressWarnings("all")
    public void tryValidate(EventType type, EventContext context) {
        if (type == MappingEventTypes.insert_before || type == MappingEventTypes.save_before) {

            boolean single = context.get(MappingContextKeys.type).map("single"::equals).orElse(false);
            if (single) {
                context.get(MappingContextKeys.instance)
                       .filter(Entity.class::isInstance)
                       .map(Entity.class::cast)
                       .ifPresent(entity -> entity.tryValidate(CreateGroup.class));
            } else {
                context.get(MappingContextKeys.instance)
                       .filter(List.class::isInstance)
                       .map(List.class::cast)
                       .ifPresent(lst -> lst.stream()
                                            .filter(Entity.class::isInstance)
                                            .map(Entity.class::cast)
                                            .forEach(e -> ((Entity) e).tryValidate(CreateGroup.class))
                       );
            }

        } else if (type == MappingEventTypes.update_before) {
            context.get(MappingContextKeys.instance)
                   .filter(Entity.class::isInstance)
                   .map(Entity.class::cast)
                   .ifPresent(entity -> entity.tryValidate(UpdateGroup.class));
        }
    }

    @Override
    public int getOrder() {
        return Ordered.LOWEST_PRECEDENCE - 1000;
    }
}

        Optional<ReactiveResultHolder> resultHolder = context.get(MappingContextKeys.reactiveResultHolder);

        if (resultHolder.isPresent()) {
            resultHolder
                    .ifPresent(holder -> holder
                            .invoke(LocaleUtils
                                            .doInReactive(() -> {
                                                tryValidate(type, context);
                                                return null;
                                            })
                            ));
        } else {
            tryValidate(type, context);
        }
    
<no_super_class>