// 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;
      case MAP: {
        StringBuilder builder = new StringBuilder();
        builder.append(formatName()).append(" = {\n");
        //noinspection unchecked
        Map<String, ?> valueMap = (Map<String, ?>) value;
        formatOptionMap(builder, valueMap);
        builder.append('}');
        return builder.toString();
      }
      case LIST: {
        StringBuilder builder = new StringBuilder();
        builder.append(formatName()).append(" = [\n");
        //noinspection unchecked
        List<OptionElement> optionList = (List<OptionElement>) value;
        formatOptionList(builder, optionList);
        builder.append(']');
        return builder.toString();
      }
      default:
        throw new AssertionError();
    }
  }

  public final String toSchemaDeclaration() {
    return "option " + toSchema() + ";\n";
  }

  static void formatOptionList(StringBuilder builder, List<OptionElement> optionList) {
    for (int i = 0, count = optionList.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;

      case MAP: {
        StringBuilder builder = new StringBuilder();
        builder.append(formatName()).append(" = {\n");
        //noinspection unchecked
        Map<String, ?> valueMap = (Map<String, ?>) value;
        formatOptionMap(builder, valueMap);
        builder.append('}');
        return builder.toString();
      }
      case LIST: {
        StringBuilder builder = new StringBuilder();
        builder.append(formatName()).append(" = [\n");
        //noinspection unchecked
        List<OptionElement> optionList = (List<OptionElement>) value;
        formatOptionList(builder, optionList);
        builder.append(']');
        return builder.toString();
      }
      default:
        throw new AssertionError();
    }
  }

  public final String toSchemaDeclaration() {
    return "option " + toSchema() + ";\n";
  }

  static void formatOptionList(StringBuilder builder, List<OptionElement> optionList) {
    for (int i = 0, count = optionList.size(); i < count; i++) {
      String endl = (i < count - 1) ? "," : "";
      appendIndented(builder, optionList.get(i).toSchema() + endl);