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

co.streamx.fluent.extree.expression.UnaryExpression Maven / Gradle / Ivy

The newest version!
package co.streamx.fluent.extree.expression;

import lombok.Getter;
import lombok.NonNull;

/**
 * Represents an expression that has a unary operator.
 * 
 * 
 */

@Getter
public class UnaryExpression extends Expression {

	private final Expression first;

	UnaryExpression(int expressionType, Class resultType, @NonNull Expression operand) {
		super(expressionType, resultType);

		this.first = operand;
	}

	@Override
	protected  T visit(ExpressionVisitor v) {
		return v.visit(this);
	}

	@Override
	public String toString() {
		StringBuilder b = new StringBuilder();

		if (getExpressionType() == ExpressionType.Convert) {
			b.append('(');
			b.append(getResultType().getName());
			b.append(')');
		} else
			b.append(ExpressionType.toString(getExpressionType()));
		b.append(getFirst().toString());

		return b.toString();
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy