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

com.laamella.sexpression.model.Comment Maven / Gradle / Ivy

There is a newer version: 0.2
Show newest version
package com.laamella.sexpression.model;

import com.laamella.sexpression.visitor.Visitor;

import java.util.function.Consumer;

public class Comment implements Node {
    public final String text;

    public Comment(String text) {
        this.text = text;
    }

    @Override
    public  R visit(Visitor visitor, A arg) throws Exception {
        return visitor.accept(this, arg);
    }

    @Override
    public Otherwise whenList(Consumer action) {
        return new Otherwise(true);
    }

    @Override
    public Otherwise whenAtom(Consumer action) {
        return new Otherwise(true);
    }

    @Override
    public Otherwise whenComment(Consumer action) {
        action.accept(this);
        return new Otherwise(false);
    }

    @Override
    public boolean isAtom() {
        return false;
    }

    @Override
    public boolean isList() {
        return false;
    }

    @Override
    public boolean isComment() {
        return true;
    }

    @Override
    public Atom toAtom() {
        throw new IllegalStateException();
    }

    @Override
    public AtomList toList() {
        throw new IllegalStateException();
    }

    @Override
    public Comment toComment() {
        return this;
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy