// Path: src/main/java/com/squareup/protoparser/Utils.java
// static void appendIndented(StringBuilder builder, String value) {
//   for (String line : value.split("\n")) {
//     builder.append("  ").append(line).append('\n');
//   }
// }
// 
// Path: src/main/java/com/squareup/protoparser/Utils.java
// static <T> T checkNotNull(T value, String name) {
//   if (value == null) {
//     throw new NullPointerException(name + " == null");
//   }
//   return value;
// }


import com.google.auto.value.AutoValue;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import static com.squareup.protoparser.Utils.appendIndented;
import static com.squareup.protoparser.Utils.checkNotNull;
import static java.util.Collections.unmodifiableMap;
    }
  }

  static void formatOptionMap(StringBuilder builder, Map<String, ?> valueMap) {
    List<? extends Map.Entry<String, ?>> entries = new ArrayList<>(valueMap.entrySet());
    for (int i = 0, count = entries.size(); i < count; i++) {
      Map.Entry<String, ?> entry = entries.get(i);
      String endl = (i < count - 1) ? "," : "";
      appendIndented(builder,
          entry.getKey() + ": " + formatOptionMapValue(entry.getValue()) + endl);
    }
  }

  static String formatOptionMapValue(Object value) {
    checkNotNull(value, "value == null");
    if (value instanceof String) {
      return "\"" + value + '"';
    }
    if (value instanceof Map) {
      StringBuilder builder = new StringBuilder().append("{\n");
      //noinspection unchecked
      Map<String, ?> map = (Map<String, ?>) value;
      formatOptionMap(builder, map);
      return builder.append('}').toString();
    }
    if (value instanceof List) {
      StringBuilder builder = new StringBuilder().append("[\n");
      List<?> list = (List<?>) value;
      for (int i = 0, count = list.size(); i < count; i++) {
        String endl = (i < count - 1) ? "," : "";
// Path: src/main/java/com/squareup/protoparser/Utils.java
// static void appendIndented(StringBuilder builder, String value) {
//   for (String line : value.split("\n")) {
//     builder.append("  ").append(line).append('\n');
//   }
// }
// 
// Path: src/main/java/com/squareup/protoparser/Utils.java
// static <T> T checkNotNull(T value, String name) {
//   if (value == null) {
//     throw new NullPointerException(name + " == null");
//   }
//   return value;
// }


// Path: src/main/java/com/squareup/protoparser/OptionElement.java
import com.google.auto.value.AutoValue;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import static com.squareup.protoparser.Utils.appendIndented;
import static com.squareup.protoparser.Utils.checkNotNull;
import static java.util.Collections.unmodifiableMap;

    }
  }

  static void formatOptionMap(StringBuilder builder, Map<String, ?> valueMap) {
    List<? extends Map.Entry<String, ?>> entries = new ArrayList<>(valueMap.entrySet());
    for (int i = 0, count = entries.size(); i < count; i++) {
      Map.Entry<String, ?> entry = entries.get(i);
      String endl = (i < count - 1) ? "," : "";
      appendIndented(builder,
          entry.getKey() + ": " + formatOptionMapValue(entry.getValue()) + endl);
    }
  }

  static String formatOptionMapValue(Object value) {
    checkNotNull(value, "value == null");
    if (value instanceof String) {
      return "\"" + value + '"';
    }
    if (value instanceof Map) {
      StringBuilder builder = new StringBuilder().append("{\n");
      //noinspection unchecked
      Map<String, ?> map = (Map<String, ?>) value;
      formatOptionMap(builder, map);
      return builder.append('}').toString();
    }
    if (value instanceof List) {
      StringBuilder builder = new StringBuilder().append("[\n");
      List<?> list = (List<?>) value;
      for (int i = 0, count = list.size(); i < count; i++) {
        String endl = (i < count - 1) ? "," : "";
        appendIndented(builder, formatOptionMapValue(list.get(i)) + endl);