class IndexingInstanceLifecycleListener implements DeleteLifecycleListener, StoreLifecycleListener {

    private final Consumer<Event> eventConsumer;

    public IndexingInstanceLifecycleListener(final Consumer<Event> eventConsumer) {
        this.eventConsumer = eventConsumer;
    }

    @Override
    public void preDelete(final InstanceLifecycleEvent event) {
        final Object instance = event.getPersistentInstance();

        if (JDOHelper.isDeleted(instance)) {
            // preDelete is called twice:
            // - once when deletePersistent(All) is called
            // - once when flushing
            // Ignore the second call to avoid duplicate IndexEvents
            return;
        }

        if (instance instanceof final Component component) {
            eventConsumer.accept(new IndexEvent(IndexEvent.Action.DELETE, component));
        } else if (instance instanceof final Project project) {
            eventConsumer.accept(new IndexEvent(IndexEvent.Action.DELETE, project));
        } else if (instance instanceof final ServiceComponent service) {
            eventConsumer.accept(new IndexEvent(IndexEvent.Action.DELETE, service));
        } else if (instance instanceof final Vulnerability vuln) {
            eventConsumer.accept(new IndexEvent(IndexEvent.Action.DELETE, vuln));
        } else if (instance instanceof final VulnerableSoftware vs) {
            eventConsumer.accept(new IndexEvent(IndexEvent.Action.DELETE, vs));
        }
    }

    @Override
    public void postDelete(final InstanceLifecycleEvent event) {
    }

    @Override
    public void preStore(final InstanceLifecycleEvent event) {<FILL_FUNCTION_BODY>}

    @Override
    public void postStore(final InstanceLifecycleEvent event) {
    }


}

        final Object instance = event.getPersistentInstance();

        final IndexEvent.Action action;
        if (JDOHelper.isNew(instance)) {
            action = IndexEvent.Action.CREATE;
        } else if (JDOHelper.isDirty(instance)) {
            action = IndexEvent.Action.UPDATE;
        } else {
            return;
        }

        if (instance instanceof final Component component) {
            eventConsumer.accept(new IndexEvent(action, component));
        } else if (instance instanceof final Project project) {
            eventConsumer.accept(new IndexEvent(action, project));
        } else if (instance instanceof final ProjectMetadata projectMetadata) {
            eventConsumer.accept(new IndexEvent(action, projectMetadata.getProject()));
        } else if (instance instanceof final ServiceComponent service) {
            eventConsumer.accept(new IndexEvent(action, service));
        } else if (instance instanceof final Vulnerability vuln) {
            eventConsumer.accept(new IndexEvent(action, vuln));
        } else if (instance instanceof final VulnerableSoftware vs) {
            eventConsumer.accept(new IndexEvent(action, vs));
        }
    
<no_super_class>