All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.fiolino.common.processing.Processor Maven / Gradle / Ivy

Go to download

General structure to easily create dynamic logic via MethodHandles and others.

There is a newer version: 1.0.10
Show newest version
package org.fiolino.common.processing;

import org.fiolino.annotations.PostProcessor;

/**
 * These entities process an existing model bean.
 * 

* Created by kuli on 18.11.15. */ public interface Processor { void process(S source, T model) throws Exception; default > X find(Class type) { return type.isInstance(this) ? type.cast(this) : null; } default Processor andThen(Processor next) { return new MultiProcessor<>(this, next); } default Processor beforeDo(Processor previous) { return previous.andThen(this); } @SuppressWarnings("unchecked") static Processor doNothing() { return (Processor) VoidProcessor.INSTANCE; } static T postProcess(T instance) { if (instance instanceof PostProcessor) { ((PostProcessor) instance).postConstruct(); } return instance; } class VoidProcessor implements Processor { private static final VoidProcessor INSTANCE = new VoidProcessor<>(); private VoidProcessor() { } @Override public void process(S source, T model) { // Do nothing } @Override @SuppressWarnings("unchecked") public Processor andThen(Processor next) { return (Processor) next; } @Override public Processor beforeDo(Processor previous) { return previous; } } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy