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

io.github.kiryu1223.expressionTree.expressions.BlockExpression Maven / Gradle / Ivy

There is a newer version: 1.4.5
Show newest version
package io.github.kiryu1223.expressionTree.expressions;

import java.util.List;

public class BlockExpression extends Expression
{
    private final List expressions;
    private final List variables;
    private final boolean isStatic;

    public BlockExpression(List expressions, List variables, boolean isStatic)
    {
        this.expressions = expressions;
        this.variables = variables;
        this.isStatic = isStatic;
    }

    public List getExpressions()
    {
        return expressions;
    }

    public List getVariables()
    {
        return variables;
    }

    public boolean isStatic()
    {
        return isStatic;
    }

    @Override
    public Kind getKind()
    {
        return Kind.Block;
    }

    @Override
    public String toString()
    {
        StringBuilder sb = new StringBuilder();
        sb.append("{\n");
        for (Expression expression : expressions)
        {
            sb.append("    ").append(expression);
            switch (expression.getKind())
            {
                case Block:
                case Lambda:
                case If:
                case Foreach:
                case For:
                case While:
                case Switch:
                case Catch:
                case Try:
                    break;
                default:
                    sb.append(";");
                    break;
            }
            sb.append("\n");
        }
        sb.append("}");
        return sb.toString();
    }

    @Override
    public boolean equals(Object obj)
    {
        if (this == obj) return true;
        if (obj == null || getClass() != obj.getClass()) return false;
        BlockExpression that = (BlockExpression) obj;
        return expressions.equals(that.expressions) && variables.equals(that.variables);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy