@Test(expectedExceptions = PatternSyntaxException.class) public void expand4() { CharSeq.expand("-az"); }
public static String expand(final CharSequence pattern) { requireNonNull(pattern, "Pattern"); final StringBuilder out = new StringBuilder(); for (int i = 0, n = pattern.length(); i < n; ++i) { if (pattern.charAt(i) == '\\') { ++i; if (i < pattern.length()) { out.append(pattern.charAt(i)); } } else if (pattern.charAt(i) == '-') { if (i <= 0 || i >= (pattern.length() - 1)) { throw new PatternSyntaxException( "Dangling range operator '-'", pattern.toString(), pattern.length() - 1 ); } final String range = expand( pattern.charAt(i - 1), pattern.charAt(i + 1) ); out.append(range); ++i; } else if (i + 1 == n || pattern.charAt(i + 1) != '-') { out.append(pattern.charAt(i)); } } return out.toString(); }
CharSeq extends CharSeqBase implements
		CharSequence,
		ISeq<Character>,
		Comparable<CharSeq>,
		Serializable { public static String expand(final CharSequence pattern) { requireNonNull(pattern, "Pattern"); final StringBuilder out = new StringBuilder(); for (int i = 0, n = pattern.length(); i < n; ++i) { if (pattern.charAt(i) == '\\') { ++i; if (i < pattern.length()) { out.append(pattern.charAt(i)); } } else if (pattern.charAt(i) == '-') { if (i <= 0 || i >= (pattern.length() - 1)) { throw new PatternSyntaxException( "Dangling range operator '-'", pattern.toString(), pattern.length() - 1 ); } final String range = expand( pattern.charAt(i - 1), pattern.charAt(i + 1) ); out.append(range); ++i; } else if (i + 1 == n || pattern.charAt(i + 1) != '-') { out.append(pattern.charAt(i)); } } return out.toString(); } }
CharSeq extends CharSeqBase implements
		CharSequence,
		ISeq<Character>,
		Comparable<CharSeq>,
		Serializable { public static String expand(final CharSequence pattern) { requireNonNull(pattern, "Pattern"); final StringBuilder out = new StringBuilder(); for (int i = 0, n = pattern.length(); i < n; ++i) { if (pattern.charAt(i) == '\\') { ++i; if (i < pattern.length()) { out.append(pattern.charAt(i)); } } else if (pattern.charAt(i) == '-') { if (i <= 0 || i >= (pattern.length() - 1)) { throw new PatternSyntaxException( "Dangling range operator '-'", pattern.toString(), pattern.length() - 1 ); } final String range = expand( pattern.charAt(i - 1), pattern.charAt(i + 1) ); out.append(range); ++i; } else if (i + 1 == n || pattern.charAt(i + 1) != '-') { out.append(pattern.charAt(i)); } } return out.toString(); } CharSeq(final char[] characters);  CharSeq(final CharSequence characters); }
CharSeq extends CharSeqBase implements
		CharSequence,
		ISeq<Character>,
		Comparable<CharSeq>,
		Serializable { public static String expand(final CharSequence pattern) { requireNonNull(pattern, "Pattern"); final StringBuilder out = new StringBuilder(); for (int i = 0, n = pattern.length(); i < n; ++i) { if (pattern.charAt(i) == '\\') { ++i; if (i < pattern.length()) { out.append(pattern.charAt(i)); } } else if (pattern.charAt(i) == '-') { if (i <= 0 || i >= (pattern.length() - 1)) { throw new PatternSyntaxException( "Dangling range operator '-'", pattern.toString(), pattern.length() - 1 ); } final String range = expand( pattern.charAt(i - 1), pattern.charAt(i + 1) ); out.append(range); ++i; } else if (i + 1 == n || pattern.charAt(i + 1) != '-') { out.append(pattern.charAt(i)); } } return out.toString(); } CharSeq(final char[] characters);  CharSeq(final CharSequence characters); @Override boolean contains(final Object object); boolean contains(final Character c); boolean contains(final char c); @Override char charAt(final int index); @Override int length(); @Override CharSeq subSequence(final int start, final int end); boolean isEmpty(); @Override int hashCode(); @Override boolean equals(final Object obj); @Override int compareTo(final CharSeq set); @Override String toString(); static String expand(final CharSequence pattern); static String expand(final char a, final char b); static CharSeq of(final CharSequence pattern); static CharSeq of(final char a, final char b); static ISeq<Character> toISeq(final CharSequence chars); static Collector<Character, ?, CharSeq> toCharSeq(); }
CharSeq extends CharSeqBase implements
		CharSequence,
		ISeq<Character>,
		Comparable<CharSeq>,
		Serializable { public static String expand(final CharSequence pattern) { requireNonNull(pattern, "Pattern"); final StringBuilder out = new StringBuilder(); for (int i = 0, n = pattern.length(); i < n; ++i) { if (pattern.charAt(i) == '\\') { ++i; if (i < pattern.length()) { out.append(pattern.charAt(i)); } } else if (pattern.charAt(i) == '-') { if (i <= 0 || i >= (pattern.length() - 1)) { throw new PatternSyntaxException( "Dangling range operator '-'", pattern.toString(), pattern.length() - 1 ); } final String range = expand( pattern.charAt(i - 1), pattern.charAt(i + 1) ); out.append(range); ++i; } else if (i + 1 == n || pattern.charAt(i + 1) != '-') { out.append(pattern.charAt(i)); } } return out.toString(); } CharSeq(final char[] characters);  CharSeq(final CharSequence characters); @Override boolean contains(final Object object); boolean contains(final Character c); boolean contains(final char c); @Override char charAt(final int index); @Override int length(); @Override CharSeq subSequence(final int start, final int end); boolean isEmpty(); @Override int hashCode(); @Override boolean equals(final Object obj); @Override int compareTo(final CharSeq set); @Override String toString(); static String expand(final CharSequence pattern); static String expand(final char a, final char b); static CharSeq of(final CharSequence pattern); static CharSeq of(final char a, final char b); static ISeq<Character> toISeq(final CharSequence chars); static Collector<Character, ?, CharSeq> toCharSeq();  }