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

org.fiolino.common.processing.sink.ConvertingSink 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 kuli on 04.01.16.
 */
public abstract class ConvertingSink extends ChainedSink {
    public ConvertingSink(Sink target) {
        super(new NullFilterSink<>(target));
    }

    /**
     * Converts the element to another type.
     *
     * @param element The element that should be added
     * @return The new element, or null if it shall be skipped
     */
    protected abstract T convert(S element, Container metadata) throws Exception;

    @Override
    public final void accept(S value, Container metadata) throws Exception {
        T newOne = convert(value, metadata);
        getTarget().accept(newOne, metadata);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy