@Test public void testSplit() { DotKeySplitter splitter = new DotKeySplitter(); assertIterator(splitter.split("a..bar:.c"), "a", "bar:", "c"); assertIterator(splitter.split(". "), " "); assertIterator(splitter.split("."), "."); assertIterator(splitter.split("foo"), "foo"); }
@Override public Iterator<String> split(String key) { if (key.equals(Strings.DOT) || key.equals(Strings.THIS) || !key.contains(Strings.DOT)) { return Iterables.singletonIterator(key); } boolean separator = false; List<String> parts = new ArrayList<>(); StringBuilder buffer = new StringBuilder(); for (int i = 0; i < key.length(); i++) { if (isSeparator(key.charAt(i))) { if (!separator) { if (buffer.length() > 0) { parts.add(buffer.toString()); buffer = new StringBuilder(); } separator = true; } } else { buffer.append(key.charAt(i)); separator = false; } } if (buffer.length() > 0) { parts.add(buffer.toString()); } return parts.iterator(); }
DotKeySplitter extends AbstractConfigurationAware implements KeySplitter { @Override public Iterator<String> split(String key) { if (key.equals(Strings.DOT) || key.equals(Strings.THIS) || !key.contains(Strings.DOT)) { return Iterables.singletonIterator(key); } boolean separator = false; List<String> parts = new ArrayList<>(); StringBuilder buffer = new StringBuilder(); for (int i = 0; i < key.length(); i++) { if (isSeparator(key.charAt(i))) { if (!separator) { if (buffer.length() > 0) { parts.add(buffer.toString()); buffer = new StringBuilder(); } separator = true; } } else { buffer.append(key.charAt(i)); separator = false; } } if (buffer.length() > 0) { parts.add(buffer.toString()); } return parts.iterator(); } }
DotKeySplitter extends AbstractConfigurationAware implements KeySplitter { @Override public Iterator<String> split(String key) { if (key.equals(Strings.DOT) || key.equals(Strings.THIS) || !key.contains(Strings.DOT)) { return Iterables.singletonIterator(key); } boolean separator = false; List<String> parts = new ArrayList<>(); StringBuilder buffer = new StringBuilder(); for (int i = 0; i < key.length(); i++) { if (isSeparator(key.charAt(i))) { if (!separator) { if (buffer.length() > 0) { parts.add(buffer.toString()); buffer = new StringBuilder(); } separator = true; } } else { buffer.append(key.charAt(i)); separator = false; } } if (buffer.length() > 0) { parts.add(buffer.toString()); } return parts.iterator(); }  }
DotKeySplitter extends AbstractConfigurationAware implements KeySplitter { @Override public Iterator<String> split(String key) { if (key.equals(Strings.DOT) || key.equals(Strings.THIS) || !key.contains(Strings.DOT)) { return Iterables.singletonIterator(key); } boolean separator = false; List<String> parts = new ArrayList<>(); StringBuilder buffer = new StringBuilder(); for (int i = 0; i < key.length(); i++) { if (isSeparator(key.charAt(i))) { if (!separator) { if (buffer.length() > 0) { parts.add(buffer.toString()); buffer = new StringBuilder(); } separator = true; } } else { buffer.append(key.charAt(i)); separator = false; } } if (buffer.length() > 0) { parts.add(buffer.toString()); } return parts.iterator(); }  @Override Iterator<String> split(String key); }
DotKeySplitter extends AbstractConfigurationAware implements KeySplitter { @Override public Iterator<String> split(String key) { if (key.equals(Strings.DOT) || key.equals(Strings.THIS) || !key.contains(Strings.DOT)) { return Iterables.singletonIterator(key); } boolean separator = false; List<String> parts = new ArrayList<>(); StringBuilder buffer = new StringBuilder(); for (int i = 0; i < key.length(); i++) { if (isSeparator(key.charAt(i))) { if (!separator) { if (buffer.length() > 0) { parts.add(buffer.toString()); buffer = new StringBuilder(); } separator = true; } } else { buffer.append(key.charAt(i)); separator = false; } } if (buffer.length() > 0) { parts.add(buffer.toString()); } return parts.iterator(); }  @Override Iterator<String> split(String key);  }