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

org.fiolino.common.processing.sink.ChainedSink 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.sink;

import org.fiolino.common.container.Container;

/**
 * Created by Michael Kuhlmann on 23.12.2015.
 */
public abstract class ChainedSink implements Sink {

    private final Sink target;

    protected ChainedSink(Sink target) {
        this.target = target;
    }

    public Sink getTarget() {
        return target;
    }

    @Override
    public void commit(Container metadata) throws Exception {
        getTarget().commit(metadata);
    }

    protected Sink targetForCloning() {
        return targetForCloning(getTarget());
    }

    public static  Sink targetForCloning(Sink target) {
        if (target instanceof CloneableSink) {
            return ((CloneableSink) target).createClone();
        }
        if (target instanceof ThreadsafeSink) {
            return target;
        }
        throw new IllegalStateException("Target " + target + " is neither thread safe nor cloneable!");
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy