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

dev.struchkov.godfather.main.domain.keyboard.simple.SimpleKeyBoard Maven / Gradle / Ivy

package dev.struchkov.godfather.main.domain.keyboard.simple;

import dev.struchkov.godfather.main.domain.keyboard.KeyBoard;
import dev.struchkov.godfather.main.domain.keyboard.KeyBoardButton;
import dev.struchkov.godfather.main.domain.keyboard.KeyBoardLine;

import java.util.ArrayList;
import java.util.List;

/**
 * Сущность клавиатуры, для создания меню с вариантами выбора.
 *
 * @author upagge [08/07/2019]
 */
public class SimpleKeyBoard implements KeyBoard {

    public static final String TYPE = "SIMPLE";

    /**
     * Строки меню.
     */
    protected List lines = new ArrayList<>();

    public SimpleKeyBoard(List lines) {
        this.lines = lines;
    }

    private SimpleKeyBoard(Builder builder) {
        lines = builder.lines;
    }

    public static SimpleKeyBoard simpleKeyboard(KeyBoardLine line) {
        return new SimpleKeyBoard(List.of(line));
    }

    public static Builder builder() {
        return new Builder();
    }

    public SimpleKeyBoard simpleKeyboard(KeyBoardButton keyBoardButton) {
        return simpleKeyboard(SimpleKeyBoardLine.simpleLine(keyBoardButton));
    }

    @Override
    public String getType() {
        return TYPE;
    }

    @Override
    public List getLines() {
        return lines;
    }

    public static final class Builder {
        private List lines = new ArrayList<>();

        private Builder() {
        }

        public Builder lines(List val) {
            lines = val;
            return this;
        }

        public Builder line(KeyBoardLine val) {
            lines.add(val);
            return this;
        }

        public SimpleKeyBoard build() {
            return new SimpleKeyBoard(this);
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy