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

org.aksw.commons.rx.op.LocalOrderSpecImpl Maven / Gradle / Ivy

package org.aksw.commons.rx.op;

import java.util.function.BiFunction;
import java.util.function.Function;

public class LocalOrderSpecImpl
    extends LocalOrderBase
    implements LocalOrderSpec
{

    public LocalOrderSpecImpl(
            Function incrementSeqId,
            BiFunction distanceFn,
            Function extractSeqId
        ) {
        super(incrementSeqId, distanceFn, extractSeqId);
    }

    @Override
    public Function getIncrementSeqId() {
        return incrementSeqId;
    }

    @Override
    public BiFunction getDistanceFn() {
        return distanceFn;
    }

    @Override
    public Function getExtractSeqId() {
        return extractSeqId;
    }


    public static  LocalOrderSpecImpl forLong(Function extractSeqId) {
        return new LocalOrderSpecImpl(
                id -> Long.valueOf(id.longValue() + 1l),
                (a, b) -> a - b,
                extractSeqId);
    }

    public static > LocalOrderSpecImpl wrap(Function incrementSeqId, BiFunction distanceFn, Function extractSeqId) {
        return new LocalOrderSpecImpl(incrementSeqId, distanceFn, extractSeqId);
    }

    public static > LocalOrderSpecImpl create(
            S initialExpectedSeqId,
            Function incrementSeqId,
            BiFunction distanceFn,
            Function extractSeqId) {
        return new LocalOrderSpecImpl(incrementSeqId, distanceFn, extractSeqId);
    }


}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy