private ParseErrorPolicy getParseErrorPolicyCheckingDeprecatedProperty()

in flume-kudu-sink/src/main/java/org/apache/flume/sink/kudu/RegexpKuduOperationsProducer.java [368:391]


  private ParseErrorPolicy getParseErrorPolicyCheckingDeprecatedProperty(
      Context context, String deprecatedPropertyName, String newPropertyName,
      ParseErrorPolicy trueValue, ParseErrorPolicy falseValue, ParseErrorPolicy defaultValue) {
    ParseErrorPolicy policy;
    if (context.containsKey(deprecatedPropertyName)) {
      logger.info("Configuration property {} is deprecated. Use {} instead.",
          deprecatedPropertyName, newPropertyName);
      Preconditions.checkArgument(!context.containsKey(newPropertyName),
          "Both {} and {} specified. Use only one of them, preferably {}.",
          deprecatedPropertyName, newPropertyName, newPropertyName);
      policy = context.getBoolean(deprecatedPropertyName) ? trueValue : falseValue;
    } else {
      String policyString = context.getString(newPropertyName, defaultValue.name());
      try {
        policy = ParseErrorPolicy.valueOf(policyString.toUpperCase(Locale.ENGLISH));
      } catch (IllegalArgumentException e) {
        throw new IllegalArgumentException(
          "Unknown policy '" + policyString + "'. Use one of the following: " +
              Arrays.toString(ParseErrorPolicy.values()), e);
      }
    }

    return policy;
  }