/** * Creates a TemplateBuilderSpec from a string. * * @param templateBuilderSpecification * the string form */ public static TemplateBuilderSpec parse(String templateBuilderSpecification) { TemplateBuilderSpec spec = new TemplateBuilderSpec(templateBuilderSpecification); if (!templateBuilderSpecification.isEmpty()) { for (String keyValuePair : KEYS_SPLITTER.split(templateBuilderSpecification)) { List<String> keyAndValue = ImmutableList.copyOf(KEY_VALUE_SPLITTER.split(keyValuePair)); checkArgument(!keyAndValue.isEmpty(), "blank key-value pair"); checkArgument(keyAndValue.size() <= 2, "key-value pair %s with more than one equals sign", keyValuePair); // Find the ValueParser for the current key. String key = keyAndValue.get(0); ValueParser valueParser = VALUE_PARSERS.get(key); checkArgument(valueParser != null, "unknown key %s", key); String value = keyAndValue.size() == 1 ? null : keyAndValue.get(1); valueParser.parse(spec, key, value); } } return spec; }
/** * Creates a TemplateBuilderSpec from a string. * * @param templateBuilderSpecification * the string form */ public static TemplateBuilderSpec parse(String templateBuilderSpecification) { TemplateBuilderSpec spec = new TemplateBuilderSpec(templateBuilderSpecification); if (!templateBuilderSpecification.isEmpty()) { for (String keyValuePair : KEYS_SPLITTER.split(templateBuilderSpecification)) { List<String> keyAndValue = ImmutableList.copyOf(KEY_VALUE_SPLITTER.split(keyValuePair)); checkArgument(!keyAndValue.isEmpty(), "blank key-value pair"); checkArgument(keyAndValue.size() <= 2, "key-value pair %s with more than one equals sign", keyValuePair); // Find the ValueParser for the current key. String key = keyAndValue.get(0); ValueParser valueParser = VALUE_PARSERS.get(key); checkArgument(valueParser != null, "unknown key %s", key); String value = keyAndValue.size() == 1 ? null : keyAndValue.get(1); valueParser.parse(spec, key, value); } } return spec; }
/** * Creates a TemplateBuilderSpec from a string. * * @param templateBuilderSpecification * the string form */ public static TemplateBuilderSpec parse(String templateBuilderSpecification) { TemplateBuilderSpec spec = new TemplateBuilderSpec(templateBuilderSpecification); if (!templateBuilderSpecification.isEmpty()) { for (String keyValuePair : KEYS_SPLITTER.split(templateBuilderSpecification)) { List<String> keyAndValue = ImmutableList.copyOf(KEY_VALUE_SPLITTER.split(keyValuePair)); checkArgument(!keyAndValue.isEmpty(), "blank key-value pair"); checkArgument(keyAndValue.size() <= 2, "key-value pair %s with more than one equals sign", keyValuePair); // Find the ValueParser for the current key. String key = keyAndValue.get(0); ValueParser valueParser = VALUE_PARSERS.get(key); checkArgument(valueParser != null, "unknown key %s", key); String value = keyAndValue.size() == 1 ? null : keyAndValue.get(1); valueParser.parse(spec, key, value); } } return spec; }
/** * Creates a TemplateBuilderSpec from a string. * * @param templateBuilderSpecification * the string form */ public static TemplateBuilderSpec parse(String templateBuilderSpecification) { TemplateBuilderSpec spec = new TemplateBuilderSpec(templateBuilderSpecification); if (!templateBuilderSpecification.isEmpty()) { for (String keyValuePair : KEYS_SPLITTER.split(templateBuilderSpecification)) { List<String> keyAndValue = ImmutableList.copyOf(KEY_VALUE_SPLITTER.split(keyValuePair)); checkArgument(!keyAndValue.isEmpty(), "blank key-value pair"); checkArgument(keyAndValue.size() <= 2, "key-value pair %s with more than one equals sign", keyValuePair); // Find the ValueParser for the current key. String key = keyAndValue.get(0); ValueParser valueParser = VALUE_PARSERS.get(key); checkArgument(valueParser != null, "unknown key %s", key); String value = keyAndValue.size() == 1 ? null : keyAndValue.get(1); valueParser.parse(spec, key, value); } } return spec; }