Skip to content

A general computation/mutation pipeline for effectively sequencing and organizing mutations on any type.

Notifications You must be signed in to change notification settings

sagansfault/berta

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

berta

A general computation/mutation pipeline for effectively sequencing and organizing mutations on any type.

Example

void run() {
    MyContext context = new MyContext();
    MyPipeline myPipeline = new MyPipeline();

    double value = 6.0;
    myPipeline.getPreMultiplier().add(c -> Optional.of(3.0));
    myPipeline.getPreMultiplier().add(c -> Optional.of(4.0));
    myPipeline.getMultiplier().add(c -> Optional.of(2.0));
    myPipeline.getMultiplier().add(c -> Optional.of(5.0));
    myPipeline.add((ctx, current) -> current * 10.0);
    value = myPipeline.mutate(context, value);

    double mirror = 6.0;
    mirror += (3.0 + 4.0);
    mirror *= (2.0 + 5.0);
    mirror *= 10.0;

    Assertions.assertEquals(mirror, value);
}

private static final class MyContext implements MutatorContext {}

private static final class MyPipeline extends SimplePipeline<MyContext, Double> {

    private final MutatorGroup<MyContext, Double> preMultiplier = new MutatorGroup<>(
            PipelineTypeSupplier.EMPTY_DOUBLE,
            DoubleMutatorFunction.ADDITIVE,
            DoubleMutatorFunction.ADDITIVE
    );
    private final MutatorGroup<MyContext, Double> multiplier = new MutatorGroup<>(
            PipelineTypeSupplier.EMPTY_DOUBLE,
            DoubleMutatorFunction.MULTIPLICATIVE,
            DoubleMutatorFunction.ADDITIVE
    );

    public MyPipeline() {
        super();
        super.add(preMultiplier);
        super.add(multiplier);
    }

    public MutatorGroup<MyContext, Double> getPreMultiplier() {
        return preMultiplier;
    }

    public MutatorGroup<MyContext, Double> getMultiplier() {
        return multiplier;
    }
}

About

A general computation/mutation pipeline for effectively sequencing and organizing mutations on any type.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages