use of org.whole.lang.exceptions.WholeIllegalArgumentException in project whole by wholeplatform.
the class MathInterpreterVisitor method visit.
@Override
public void visit(ExclusiveOr entity) {
boolean value = false;
for (int i = 0, size = entity.size(); i < size; i++) {
IEntity result = evaluate(entity.get(i));
DataKinds dataKinds = DataTypeUtils.getUnboxedDataKind(result);
if (dataKinds.isNotAData())
throw new WholeIllegalArgumentException(WholeMessages.no_data).withSourceEntity(entity).withBindings(getBindings());
else if (!dataKinds.isBoolean())
throw new WholeIllegalArgumentException(WholeMessages.illegal_data_conversion).withSourceEntity(entity).withBindings(getBindings());
else
value ^= result.wBooleanValue();
}
setResult(createBooleanLiteral(value));
}
use of org.whole.lang.exceptions.WholeIllegalArgumentException in project whole by wholeplatform.
the class MathInterpreterVisitor method visit.
@Override
public void visit(Or entity) {
boolean value = false;
for (int i = 0, size = entity.size(); i < size; i++) {
IEntity result = evaluate(entity.get(i));
DataKinds dataKinds = DataTypeUtils.getUnboxedDataKind(result);
if (dataKinds.isNotAData())
throw new WholeIllegalArgumentException(WholeMessages.no_data).withSourceEntity(entity).withBindings(getBindings());
else if (!dataKinds.isBoolean())
throw new WholeIllegalArgumentException(WholeMessages.illegal_data_conversion).withSourceEntity(entity).withBindings(getBindings());
else if (value |= result.wBooleanValue())
break;
}
setResult(createBooleanLiteral(value));
}
use of org.whole.lang.exceptions.WholeIllegalArgumentException in project whole by wholeplatform.
the class MathInterpreterVisitor method visit.
@Override
public void visit(And entity) {
boolean value = true;
for (int i = 0, size = entity.size(); i < size; i++) {
IEntity result = evaluate(entity.get(i));
DataKinds dataKinds = DataTypeUtils.getUnboxedDataKind(result);
if (dataKinds.isNotAData())
throw new WholeIllegalArgumentException(WholeMessages.no_data).withSourceEntity(entity).withBindings(getBindings());
else if (!dataKinds.isBoolean())
throw new WholeIllegalArgumentException(WholeMessages.illegal_data_conversion).withSourceEntity(entity).withBindings(getBindings());
else if (!(value &= result.wBooleanValue()))
break;
}
setResult(createBooleanLiteral(value));
}
use of org.whole.lang.exceptions.WholeIllegalArgumentException in project whole by wholeplatform.
the class AbstractISO8601DataTypeParser method parseObject.
public Object parseObject(EntityDescriptor<?> ed, String value) {
DateTimeParser parser = getFormatter().getParser();
DateTimeParserBucket bucket = new DateTimeParserBucket(0, ISOChronology.getInstance(), null);
// use a custom UTC to check if offset part is parsed
if (bucket.getZone() == null)
bucket.setZone(UTC);
if (parser.parseInto(bucket, value, 0) < 0)
throw new WholeIllegalArgumentException(WholeMessages.no_data_type);
DateTimeZone zone = bucket.getZone();
if (zone == null)
return parseWithTimeZone(bucket);
else
return parseWithoutTimeZone(bucket);
}
use of org.whole.lang.exceptions.WholeIllegalArgumentException in project whole by wholeplatform.
the class TestsDataTypePresentationParser method parseEnumValue.
public EnumValue parseEnumValue(EntityDescriptor<?> ed, String value) {
if (TestsEntityDescriptorEnum.CommentKind_ord == ed.getOrdinal()) {
EnumType<?> dataEnumType = ed.getDataEnumType();
if (dataEnumType == null)
throw new WholeIllegalArgumentException(WholeMessages.no_data_type);
EnumValue result = dataEnumType.valueOf(value);
if (result == null)
throw new WholeIllegalArgumentException(WholeMessages.no_data_type);
return result;
} else
return super.parseEnumValue(ed, value);
}
Aggregations