use of com.icodici.universa.Decimal in project universa by UniversaBlockchain.
the class SplitJoinPermission method checkSplit.
private void checkSplit(Contract changed, MapDelta<String, Binder, Binder> dataChanges, Decimal oldValue, Decimal newValue) {
boolean isValid;
// We need to find the splitted contracts
Decimal sum = Decimal.ZERO;
for (Contract s : changed.getSiblings()) {
if (!isMergeable(s) || !validateMergeFields(changed, s))
return;
sum = sum.add(new Decimal(s.getStateData().getString(fieldName)));
}
// total value should not be changed or check split-join case
isValid = sum.equals(oldValue);
if (!isValid)
isValid = checkSplitJoinCase(changed);
if (isValid && newValue.compareTo(minValue) >= 0 && newValue.ulp().compareTo(minUnit) >= 0)
dataChanges.remove(fieldName);
}
Aggregations