use of com.storedobject.ui.util.AbstractQuantityField in project SODevelopment by syampillai.
the class MeasurementField method createQField.
private static <Q extends Quantity> AbstractQuantityField<Q> createQField(Class<Q> quantityClass, int width, int decimals, MeasurementUnit unit) {
if (unit == null) {
try {
unit = quantityClass.getDeclaredConstructor().newInstance().getUnit();
} catch (Throwable ignored) {
}
}
String name = quantityClass.getName();
name = "com.storedobject.ui." + name.substring(name.lastIndexOf('.') + 1) + "Field";
try {
// noinspection unchecked
return (AbstractQuantityField<Q>) Class.forName(name).getDeclaredConstructor(int.class, int.class, MeasurementUnit.class).newInstance(width, decimals, unit);
} catch (Throwable e) {
throw new SORuntimeException(e);
}
}
Aggregations