Пример #1
0
  public static Double processValue(Target target, Double value) {
    double result = value.doubleValue();

    Double min = target.getMin();
    if (min != null) {
      result = Math.max(result, min.doubleValue());
    }

    Double max = target.getMax();
    if (max != null) {
      result = Math.min(result, max.doubleValue());
    }

    result = (result * target.getRescaleFactor()) + target.getRescaleConstant();

    Target.CastInteger castInteger = target.getCastInteger();
    if (castInteger == null) {
      return result;
    }

    switch (castInteger) {
      case ROUND:
        return (double) Math.round(result);
      case CEILING:
        return Math.ceil(result);
      case FLOOR:
        return Math.floor(result);
      default:
        throw new UnsupportedFeatureException(target, castInteger);
    }
  }