@Test public void testGetPlaceholderAttributes() { final DynamicPathTemplate path = new DynamicPathTemplate("${foo:-f}/${bar:-b}/${baz:-bz}"); final ImmutableList<String> values = ImmutableList.of("one", "two", "three"); final ImmutableMap<String, String> expect = ImmutableMap.of("foo", "one", "bar", "two", "baz", "three"); assertEquals(expect, path.getPlaceholderAttributes(values)); }
public Map<String, String> getPlaceholderAttributes(List<String> values) { if (values.size() != placeholderNames.size()) { throw new IllegalArgumentException(String.format( "The number of passed values (%d) did not match the number of placeholders (%d)", values.size(), placeholderNames.size())); } Map<String, String> attributes = new HashMap<>(values.size()); for (int i = 0; i < values.size(); i++) { attributes.put(placeholderNames.get(i), values.get(i)); } return attributes; }
DynamicPathTemplate implements Serializable { public Map<String, String> getPlaceholderAttributes(List<String> values) { if (values.size() != placeholderNames.size()) { throw new IllegalArgumentException(String.format( "The number of passed values (%d) did not match the number of placeholders (%d)", values.size(), placeholderNames.size())); } Map<String, String> attributes = new HashMap<>(values.size()); for (int i = 0; i < values.size(); i++) { attributes.put(placeholderNames.get(i), values.get(i)); } return attributes; } }
DynamicPathTemplate implements Serializable { public Map<String, String> getPlaceholderAttributes(List<String> values) { if (values.size() != placeholderNames.size()) { throw new IllegalArgumentException(String.format( "The number of passed values (%d) did not match the number of placeholders (%d)", values.size(), placeholderNames.size())); } Map<String, String> attributes = new HashMap<>(values.size()); for (int i = 0; i < values.size(); i++) { attributes.put(placeholderNames.get(i), values.get(i)); } return attributes; } DynamicPathTemplate(String rawPath); }
DynamicPathTemplate implements Serializable { public Map<String, String> getPlaceholderAttributes(List<String> values) { if (values.size() != placeholderNames.size()) { throw new IllegalArgumentException(String.format( "The number of passed values (%d) did not match the number of placeholders (%d)", values.size(), placeholderNames.size())); } Map<String, String> attributes = new HashMap<>(values.size()); for (int i = 0; i < values.size(); i++) { attributes.put(placeholderNames.get(i), values.get(i)); } return attributes; } DynamicPathTemplate(String rawPath); List<String> getPlaceholderNames(); Map<String, String> getPlaceholderAttributes(List<String> values); String replaceDynamicPart(List<String> values); List<String> extractValuesFrom(Map<String, String> attributes); }
DynamicPathTemplate implements Serializable { public Map<String, String> getPlaceholderAttributes(List<String> values) { if (values.size() != placeholderNames.size()) { throw new IllegalArgumentException(String.format( "The number of passed values (%d) did not match the number of placeholders (%d)", values.size(), placeholderNames.size())); } Map<String, String> attributes = new HashMap<>(values.size()); for (int i = 0; i < values.size(); i++) { attributes.put(placeholderNames.get(i), values.get(i)); } return attributes; } DynamicPathTemplate(String rawPath); List<String> getPlaceholderNames(); Map<String, String> getPlaceholderAttributes(List<String> values); String replaceDynamicPart(List<String> values); List<String> extractValuesFrom(Map<String, String> attributes); final String staticPrefix; final String dynamicPart; }