use of permafrost.tundra.data.IDataMap in project Tundra by Permafrost.
the class integer method multiply.
public static final void multiply(IData pipeline) throws ServiceException {
// --- <<IS-START(multiply)>> ---
// @subtype unknown
// @sigtype java 3.5
// [i] record:0:optional $operands
// [o] field:0:optional $result
IDataCursor cursor = pipeline.getCursor();
try {
IData operands = IDataHelper.get(cursor, "$operands", IData.class);
// support $integers and $integer input for backwards-compatibility
boolean backwardsCompatiblityRequired = false;
if (operands == null) {
String[] list = IDataHelper.get(cursor, "$integers", String[].class);
String integer = IDataHelper.get(cursor, "$integer", String.class);
IDataMap map = new IDataMap();
if (list != null)
map.put("$integers", list);
if (integer != null)
map.put("$integer", integer);
operands = map;
backwardsCompatiblityRequired = true;
}
BigInteger result = BigIntegerHelper.multiply(BigIntegerHelper.normalize(IDataHelper.getLeafValues(operands)));
if (backwardsCompatiblityRequired) {
IDataHelper.put(cursor, "$integer", result, String.class, false);
} else {
IDataHelper.put(cursor, "$result", result, String.class, false);
}
} finally {
cursor.destroy();
}
// --- <<IS-END>> ---
}
use of permafrost.tundra.data.IDataMap in project Tundra by Permafrost.
the class integer method add.
public static final void add(IData pipeline) throws ServiceException {
// --- <<IS-START(add)>> ---
// @subtype unknown
// @sigtype java 3.5
// [i] record:0:optional $operands
// [o] field:0:optional $result
IDataCursor cursor = pipeline.getCursor();
try {
IData operands = IDataHelper.get(cursor, "$operands", IData.class);
// support $integers and $integer inputs for backwards-compatibility
boolean backwardsCompatiblityRequired = false;
if (operands == null) {
String[] list = IDataHelper.get(cursor, "$integers", String[].class);
String integer = IDataHelper.get(cursor, "$integer", String.class);
IDataMap map = new IDataMap();
if (list != null)
map.put("$integers", list);
if (integer != null)
map.put("$integer", integer);
operands = map;
backwardsCompatiblityRequired = true;
}
BigInteger result = BigIntegerHelper.add(BigIntegerHelper.normalize(IDataHelper.getLeafValues(operands)));
if (backwardsCompatiblityRequired) {
IDataHelper.put(cursor, "$integer", result, String.class, false);
} else {
IDataHelper.put(cursor, "$result", result, String.class, false);
}
} finally {
cursor.destroy();
}
// --- <<IS-END>> ---
}
use of permafrost.tundra.data.IDataMap in project Tundra by Permafrost.
the class integer method maximum.
public static final void maximum(IData pipeline) throws ServiceException {
// --- <<IS-START(maximum)>> ---
// @subtype unknown
// @sigtype java 3.5
// [i] record:0:optional $operands
// [o] field:0:optional $maximum
IDataCursor cursor = pipeline.getCursor();
try {
IData operands = IDataHelper.get(cursor, "$operands", IData.class);
// support $integers input for backwards-compatibility
boolean backwardsCompatiblityRequired = false;
if (operands == null) {
String[] list = IDataHelper.get(cursor, "$integers", String[].class);
IDataMap map = new IDataMap();
if (list != null)
map.put("$integers", list);
operands = map;
backwardsCompatiblityRequired = true;
}
BigInteger result = BigIntegerHelper.maximum(BigIntegerHelper.normalize(IDataHelper.getLeafValues(operands)));
if (backwardsCompatiblityRequired) {
IDataHelper.put(cursor, "$integer", result, String.class, false);
} else {
IDataHelper.put(cursor, "$maximum", result, String.class, false);
}
} finally {
cursor.destroy();
}
// --- <<IS-END>> ---
}
use of permafrost.tundra.data.IDataMap in project Tundra by Permafrost.
the class decimal method average.
public static final void average(IData pipeline) throws ServiceException {
// --- <<IS-START(average)>> ---
// @subtype unknown
// @sigtype java 3.5
// [i] record:0:optional $operands
// [i] field:0:optional $precision
// [i] field:0:optional $rounding {"HALF_UP","CEILING","DOWN","FLOOR","HALF_DOWN","HALF_EVEN","UNNECESSARY","UP"}
// [o] field:0:optional $average
IDataCursor cursor = pipeline.getCursor();
try {
IData operands = IDataHelper.get(cursor, "$operands", IData.class);
int precision = IDataHelper.getOrDefault(cursor, "$precision", Integer.class, -1);
RoundingMode rounding = IDataHelper.get(cursor, "$rounding", RoundingMode.class);
// support $decimals input for backwards-compatibility
boolean backwardsCompatiblityRequired = false;
if (operands == null) {
String[] list = IDataHelper.get(cursor, "$decimals", String[].class);
IDataMap map = new IDataMap();
if (list != null)
map.put("$decimals", list);
operands = map;
backwardsCompatiblityRequired = true;
}
BigDecimal result = BigDecimalHelper.average(precision, rounding, BigDecimalHelper.normalize(IDataHelper.getLeafValues(operands)));
if (backwardsCompatiblityRequired) {
IDataHelper.put(cursor, "$decimal", result, String.class, false);
} else {
IDataHelper.put(cursor, "$average", result, String.class, false);
}
} finally {
cursor.destroy();
}
// --- <<IS-END>> ---
}
use of permafrost.tundra.data.IDataMap in project Tundra by Permafrost.
the class decimal method add.
public static final void add(IData pipeline) throws ServiceException {
// --- <<IS-START(add)>> ---
// @subtype unknown
// @sigtype java 3.5
// [i] record:0:optional $operands
// [i] field:0:optional $precision
// [i] field:0:optional $rounding {"HALF_UP","CEILING","DOWN","FLOOR","HALF_DOWN","HALF_EVEN","UNNECESSARY","UP"}
// [o] field:0:optional $result
IDataCursor cursor = pipeline.getCursor();
try {
IData operands = IDataHelper.get(cursor, "$operands", IData.class);
int precision = IDataHelper.getOrDefault(cursor, "$precision", Integer.class, -1);
RoundingMode rounding = IDataHelper.get(cursor, "$rounding", RoundingMode.class);
// support $decimals and $decimal inputs for backwards-compatibility
boolean backwardsCompatiblityRequired = false;
if (operands == null) {
String[] list = IDataHelper.get(cursor, "$decimals", String[].class);
String decimal = IDataHelper.get(cursor, "$decimal", String.class);
IDataMap map = new IDataMap();
if (list != null)
map.put("$decimals", list);
if (decimal != null)
map.put("$decimal", decimal);
operands = map;
backwardsCompatiblityRequired = true;
}
BigDecimal[] decimals = BigDecimalHelper.normalize(IDataHelper.getLeafValues(operands));
BigDecimal result = BigDecimalHelper.round(BigDecimalHelper.add(decimals), precision, rounding);
if (backwardsCompatiblityRequired) {
IDataHelper.put(cursor, "$decimal", result, String.class, false);
} else {
IDataHelper.put(cursor, "$result", result, String.class, false);
}
} finally {
cursor.destroy();
}
// --- <<IS-END>> ---
}
Aggregations