use of org.whole.lang.exceptions.WholeIllegalArgumentException in project whole by wholeplatform.
the class MathUtils method subtraction.
public static IEntity subtraction(IEntity result1, IEntity result2) {
DataKinds dataKind1 = DataTypeUtils.getUnboxedDataKind(result1);
DataKinds dataKind2 = DataTypeUtils.getUnboxedDataKind(result2);
IEntity result;
if (dataKind1.isNotAData() || dataKind2.isNotAData())
throw new WholeIllegalArgumentException(WholeMessages.no_data);
else if (dataKind1.isDouble() || dataKind2.isDouble())
result = BindingManagerFactory.instance.createValue(DataTypeUtils.toDouble(result1) - DataTypeUtils.toDouble(result2));
else if (dataKind1.isFloat() || dataKind2.isFloat())
result = BindingManagerFactory.instance.createValue(DataTypeUtils.toFloat(result1) - DataTypeUtils.toFloat(result2));
else if (dataKind1.isLong() || dataKind2.isLong())
result = BindingManagerFactory.instance.createValue(DataTypeUtils.toLong(result1) - DataTypeUtils.toLong(result2));
else
result = BindingManagerFactory.instance.createValue(DataTypeUtils.toInt(result1) - DataTypeUtils.toInt(result2));
return result;
}
use of org.whole.lang.exceptions.WholeIllegalArgumentException in project whole by wholeplatform.
the class MathUtils method multiplication.
public static IEntity multiplication(IEntity result1, IEntity result2) {
DataKinds dataKind1 = DataTypeUtils.getUnboxedDataKind(result1);
DataKinds dataKind2 = DataTypeUtils.getUnboxedDataKind(result2);
IEntity result;
if (dataKind1.isNotAData() || dataKind2.isNotAData())
throw new WholeIllegalArgumentException(WholeMessages.no_data);
else if (dataKind1.isDouble() || dataKind2.isDouble())
result = BindingManagerFactory.instance.createValue(DataTypeUtils.toDouble(result1) * DataTypeUtils.toDouble(result2));
else if (dataKind1.isFloat() || dataKind2.isFloat())
result = BindingManagerFactory.instance.createValue(DataTypeUtils.toFloat(result1) * DataTypeUtils.toFloat(result2));
else if (dataKind1.isLong() || dataKind2.isLong())
result = BindingManagerFactory.instance.createValue(DataTypeUtils.toLong(result1) * DataTypeUtils.toLong(result2));
else
result = BindingManagerFactory.instance.createValue(DataTypeUtils.toInt(result1) * DataTypeUtils.toInt(result2));
return result;
}
use of org.whole.lang.exceptions.WholeIllegalArgumentException in project whole by wholeplatform.
the class CommonsDataTypePresentationParser method parseEntityDescriptor.
public static EntityDescriptor<? extends IEntity> parseEntityDescriptor(String value) {
int index = value.indexOf('#');
if (index > 0) {
String languageUri = value.substring(0, index);
ILanguageKit lk = /*= null;
if (ReflectionFactory.hasLanguageKit(languageUri)) {
for (ILanguageKit lk2 : ReflectionFactory.getLanguageKits(true))
if (lk2.getName().equalsIgnoreCase(languageUri)) {
lk = lk2;
break;
}
}
if (lk == null)
lk*/
ReflectionFactory.getLanguageKit(languageUri);
EntityDescriptor<?> ed = lk.getEntityDescriptorEnum().valueOf(value.substring(index + 1));
if (ed != null)
return ed;
}
throw new WholeIllegalArgumentException(WholeMessages.no_data_type);
}
use of org.whole.lang.exceptions.WholeIllegalArgumentException in project whole by wholeplatform.
the class DefaultDataTypePresentationParser method parseEnumValue.
public EnumValue parseEnumValue(EntityDescriptor<?> ed, String value) {
EnumType<?> dataEnumType = ed.getDataEnumType();
if (dataEnumType == null)
throw new WholeIllegalArgumentException(WholeMessages.no_data_type);
EnumValue result = dataEnumType.valueOf(value);
if (result != null)
return result;
for (Iterator<? extends EnumValue> i = dataEnumType.iterator(); i.hasNext(); ) {
EnumValue enumValue = i.next();
if (enumValue.getName().equalsIgnoreCase(value))
return enumValue;
}
throw new WholeIllegalArgumentException(WholeMessages.no_data_type);
}
use of org.whole.lang.exceptions.WholeIllegalArgumentException in project whole by wholeplatform.
the class DefaultDataTypePersistenceParser method parseEnumValue.
public EnumValue parseEnumValue(EntityDescriptor<?> ed, String value) {
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;
}
Aggregations