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

tw.yukina.notion.sdk.builder.RichTextBuilder Maven / Gradle / Ivy

There is a newer version: 1.0.1
Show newest version
package tw.yukina.notion.sdk.builder;

import org.jetbrains.annotations.NotNull;
import tw.yukina.notion.sdk.model.TextColor;
import tw.yukina.notion.sdk.model.common.rich.Annotation;
import tw.yukina.notion.sdk.model.common.rich.RichText;

public abstract class RichTextBuilder {

    private boolean isBold = false;

    private boolean isItalic = false;

    private boolean isStrikethrough = false;

    private boolean isUnderline = false;

    private boolean isCode = false;

    private TextColor color = TextColor.DEFAULT;

    public RichTextBuilder setBold(){
        this.isBold = true;
        return this;
    }

    public RichTextBuilder setItalic(){
        this.isItalic = true;
        return this;
    }

    public RichTextBuilder setStrolethrough(){
        this.isStrikethrough = true;
        return this;
    }

    public RichTextBuilder setUnderline(){
        this.isUnderline = true;
        return this;
    }

    public RichTextBuilder setCodeStyle(){
        this.isCode = true;
        return this;
    }

    public RichTextBuilder setColor(@NotNull TextColor color){
        this.color = color;
        return this;
    }

    public abstract T build();

    protected void setRichTextStyle(@NotNull T richText){
        Annotation annotation = new Annotation();
        annotation.setBold(this.isBold);
        annotation.setItalic(this.isItalic);
        annotation.setStrikethrough(this.isStrikethrough);
        annotation.setUnderline(this.isUnderline);
        annotation.setCode(this.isCode);
        annotation.setColor(this.color);
        richText.setAnnotations(annotation);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy