io.github.vmzakharov.ecdataframe.dsl.value.BooleanValue Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of dataframe-ec Show documentation
Show all versions of dataframe-ec Show documentation
A tabular data structure based on the Eclipse Collections framework
package io.github.vmzakharov.ecdataframe.dsl.value;
import io.github.vmzakharov.ecdataframe.dsl.ArithmeticOp;
import io.github.vmzakharov.ecdataframe.dsl.UnaryOp;
import static io.github.vmzakharov.ecdataframe.util.ExceptionFactory.exceptionByKey;
abstract public class BooleanValue
extends AbstractValue
implements Value
{
static public final BooleanValue TRUE = new BooleanValue()
{
@Override
public boolean isTrue()
{
return true;
}
@Override
public boolean isFalse()
{
return false;
}
@Override
public boolean is(boolean booleanValue)
{
return booleanValue;
}
@Override
public String asStringLiteral()
{
return "TRUE";
}
};
static public final BooleanValue FALSE = new BooleanValue()
{
@Override
public boolean isTrue()
{
return false;
}
@Override
public boolean isFalse()
{
return true;
}
@Override
public boolean is(boolean booleanValue)
{
return !booleanValue;
}
@Override
public String asStringLiteral()
{
return "FALSE";
}
};
public static BooleanValue valueOf(boolean value)
{
return value ? TRUE : FALSE;
}
@Override
public Value apply(Value another, ArithmeticOp operation)
{
throw exceptionByKey("DSL_OP_NOT_SUPPORTED")
.with("operation", operation.asString())
.with("type", this.getType().toString())
.getUnsupported();
}
@Override
public Value apply(UnaryOp operation)
{
return operation.applyBoolean(this.isTrue());
}
public abstract boolean isTrue();
public abstract boolean isFalse();
public abstract boolean is(boolean booleanValue);
@Override
public ValueType getType()
{
return ValueType.BOOLEAN;
}
@Override
public int compareTo(Value other)
{
this.checkSameTypeForComparison(other);
return Boolean.compare(this.isTrue(), ((BooleanValue) other).isTrue());
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy