static PiranhaMethodRecord parseFromJSONPropertyEntryMap()

in legacy/java/piranha/src/main/java/com/uber/piranha/config/PiranhaMethodRecord.java [73:106]


  static PiranhaMethodRecord parseFromJSONPropertyEntryMap(
      Map<String, Object> methodPropertyEntry, boolean isArgumentIndexOptional)
      throws PiranhaConfigurationException {
    String methodName = getValueStringFromMap(methodPropertyEntry, METHOD_NAME_KEY);
    String flagType = getValueStringFromMap(methodPropertyEntry, FLAG_TYPE_KEY);
    Integer argumentIndexInteger = getArgumentIndexFromMap(methodPropertyEntry, ARGUMENT_INDEX_KEY);
    if (methodName == null) {
      throw new PiranhaConfigurationException(
          "methodProperty is missing mandatory methodName field. Check:\n" + methodPropertyEntry);
    } else if (flagType == null) {
      throw new PiranhaConfigurationException(
          "methodProperty is missing mandatory flagType field. Check:\n" + methodPropertyEntry);
    } else if (!isArgumentIndexOptional && argumentIndexInteger == null) {
      throw new PiranhaConfigurationException(
          "methodProperty did not have argumentIndex. By default, Piranha requires an argument index for flag "
              + "APIs, to which the flag name/symbol will be passed. This is to avoid over-deletion of all "
              + "occurrences of a flag API method. If you are sure you want to delete all instances of the "
              + "method below, consider using Piranha:ArgumentIndexOptional=true to override this behavior. "
              + "Check:\n"
              + methodPropertyEntry);
    } else if (argumentIndexInteger != null && argumentIndexInteger < 0) {
      throw new PiranhaConfigurationException(
          "Invalid argumentIndex field. Arguments are zero indexed. Check:\n"
              + methodPropertyEntry);
    }

    return new PiranhaMethodRecord(
        methodName,
        flagType,
        argumentIndexInteger,
        getValueStringFromMap(methodPropertyEntry, RECEIVER_TYPE_STRING),
        getValueStringFromMap(methodPropertyEntry, RETURN_TYPE_STRING),
        getValueBooleanFromMap(methodPropertyEntry, METHOD_IS_STATIC));
  }