public static ThresholdValue tryParse()

in dotTrace-server/src/main/java/jetbrains/buildServer/dotTrace/server/ThresholdValue.java [26:63]


  public static ThresholdValue tryParse(@Nullable final String valueStr) {
    if(valueStr == null) {
      return null;
    }

    final Matcher matcher = statisticPattern.matcher(valueStr.trim());
    if(!matcher.find()) {
      return null;
    }

    if(matcher.groupCount() != 4) {
      return null;
    }

    @Nullable
    final String absoluteValStr = matcher.group(4);
    if(absoluteValStr != null) {
      final BigDecimal decimalVal = new BigDecimal(absoluteValStr);
      if(SKIPPED_DECIMAL_VALUE.equals(decimalVal)) {
        return SKIPPED_THRESHOLD_VALUE;
      }

      return new ThresholdValue(ThresholdValueType.ABSOLUTE, decimalVal);
    }

    final ThresholdValueType type = ThresholdValueType.tryParse(matcher.group(2));
    if(type == null) {
      return null;
    }

    try {
      return new ThresholdValue(type, new BigDecimal(matcher.group(3)));
    }
    catch (NumberFormatException ignored) {
    }

    return null;
  }