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

org.fxmisc.richtext.model.TextOps Maven / Gradle / Ivy

The newest version!
package org.fxmisc.richtext.model;

import org.reactfx.util.Either;

public interface TextOps extends SegmentOps {
    public SEG create(String text, S style);

    public default  TextOps, S> _or(SegmentOps rOps) {
        return eitherL(this, rOps);
    }

    public static  TextOps, S> eitherL(TextOps lOps, SegmentOps rOps) {
        return new LeftTextOps<>(lOps, rOps);
    }

    public static  TextOps, S> eitherR(SegmentOps lOps, TextOps rOps) {
        return new RightTextOps<>(lOps, rOps);
    }

}

class LeftTextOps extends EitherSegmentOps implements TextOps, S> {

    private final TextOps lOps;

    LeftTextOps(TextOps lOps, SegmentOps rOps) {
        super(lOps, rOps);
        this.lOps = lOps;
    }

    @Override
    public Either create(String text, S style) {
        return Either.left(lOps.create(text, style));
    }

}

class RightTextOps extends EitherSegmentOps implements TextOps, S> {

    private final TextOps rOps;

    RightTextOps(SegmentOps lOps, TextOps rOps) {
        super(lOps, rOps);
        this.rOps = rOps;
    }

    @Override
    public Either create(String text, S style) {
        return Either.right(rOps.create(text, style));
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy