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

io.github.kiryu1223.expressionTree.expressions.SwitchExpression 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 SwitchExpression extends Expression
{
    private final Expression selector;
    private final List cases;

    public SwitchExpression(Expression selector, List cases)
    {
        this.selector = selector;
        this.cases = cases;
    }

    public Expression getSelector()
    {
        return selector;
    }

    public List getCases()
    {
        return cases;
    }

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

    @Override
    public String toString()
    {
        StringBuilder sb = new StringBuilder();
        sb.append("switch ").append(selector).append(" ").append("{\n");
        for (CaseExpression aCase : cases)
        {
            sb.append("    ").append(aCase).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;
        SwitchExpression that = (SwitchExpression) obj;
        return selector.equals(that.selector)&&cases.equals(that.cases);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy