class Ingredient {

  protected void setCompoundOptional(String name, boolean repeatable, Object... keyValuePairs) {
    if (keyValuePairs.length % 2 != 0) {
      throw new IllegalArgumentException(
          "must have an even number of key-value pairs for compound optional");
    }

    for (int i = 0; i < keyValuePairs.length; i += 2) {
      if (!(keyValuePairs[i] instanceof String)) {
        throw new IllegalArgumentException("key in compound optional is not a string");
      }
    }

    if (!repeatable) {
      Map map = (Map) getProperties().getOrDefault(name, new HashMap());
      for (int i = 0; i < keyValuePairs.length; i += 2) {
        map.put(keyValuePairs[i], keyValuePairs[i + 1]);
      }
      setProperty(name, map);
    } else {
      List<Map> list = (List) getProperties().getOrDefault(name, new ArrayList<>());
      Map map = new HashMap();
      for (int i = 0; i < keyValuePairs.length; i += 2) {
        map.put(keyValuePairs[i], keyValuePairs[i + 1]);
      }
      list.add(map);
      setProperty(name, list);
    }
  }

  public  Ingredient(String ingredientType, String domain);
  public  Ingredient(String ingredientType);
  protected  Ingredient(Ingredient other);

}