import { FCloudDataType } from '../model/shared/data-type/fcloud-data-Type';
import { isNil } from 'lodash';
export class OperationHelper {
    static add(value, operand, dataType, maxValue) {
        if (!dataType) {
            return value + operand;
        }
        if (!isNil(maxValue)) {
            return Math.min(value + operand, maxValue);
        }
        return Math.min(value + operand, OperationHelper.getMax(dataType));
    }
    static subtract(value, operand, dataType, minValue) {
        if (!dataType) {
            return value - operand;
        }
        if (!isNil(minValue)) {
            return Math.max(value - operand, minValue);
        }
        return Math.max(value - operand, OperationHelper.getMin(dataType));
    }
    static getMax(dataType) {
        switch (dataType) {
            case FCloudDataType.Int32:
                return 2147483647;
            case FCloudDataType.Float:
                return 3.402823E+38;
        }
    }
    static getMin(dataType) {
        switch (dataType) {
            case FCloudDataType.Int32:
                return -2147483648;
            case FCloudDataType.Float:
                return -3.402823E+38;
        }
    }
}
