List of usage examples for com.google.common.primitives Chars toArray
public static char[] toArray(Collection<Character> collection)
From source file:be.fror.password.rule.Ruler.java
private Generator createGenerator() { final ImmutableSet<CharacterRule> charRules = rules.stream().filter(e -> e instanceof CharacterRule) .map(e -> (CharacterRule) e).collect(MoreCollectors.toImmutableSet()); checkState(!charRules.isEmpty(), "No CharacterRule were added to this Ruler"); Set<Character> uniqueChars = new TreeSet<>(); int minLen = 0; for (CharacterRule rule : charRules) { for (char c : rule.getValidCharacters().toCharArray()) { uniqueChars.add(c);// w w w . j av a 2s .c om } minLen += rule.getNumberOfCharacters(); } return new Generator(charRules, Chars.toArray(uniqueChars), minLen); }
From source file:com.google.javascript.jscomp.RandomNameGenerator.java
private static String shuffleAndCopyAlphabet(Set<Character> input, Random random) { List<Character> shuffled = new ArrayList<>(input); Collections.shuffle(shuffled, random); return new String(Chars.toArray(shuffled)); }
From source file:org.eclipse.xtend.core.macro.declaration.CompilationUnitImpl.java
private Object toArrayOfType(final Iterable<?> iterable, final Class<?> componentType) { Collection<?> _xifexpression = null; if ((iterable instanceof Collection<?>)) { _xifexpression = ((Collection<?>) iterable); } else {/*from w ww . jav a2 s.co m*/ _xifexpression = IterableExtensions.toList(iterable); } final Collection<?> collection = _xifexpression; Object _switchResult = null; boolean _matched = false; if (Objects.equal(componentType, int.class)) { _matched = true; _switchResult = Ints.toArray(((List<Integer>) collection)); } if (!_matched) { if (Objects.equal(componentType, long.class)) { _matched = true; _switchResult = Longs.toArray(((List<Long>) collection)); } } if (!_matched) { if (Objects.equal(componentType, char.class)) { _matched = true; _switchResult = Chars.toArray(((List<Character>) collection)); } } if (!_matched) { if (Objects.equal(componentType, boolean.class)) { _matched = true; _switchResult = Booleans.toArray(((List<Boolean>) collection)); } } if (!_matched) { if (Objects.equal(componentType, byte.class)) { _matched = true; _switchResult = Bytes.toArray(((List<Byte>) collection)); } } if (!_matched) { if (Objects.equal(componentType, short.class)) { _matched = true; _switchResult = Shorts.toArray(((List<Short>) collection)); } } if (!_matched) { if (Objects.equal(componentType, float.class)) { _matched = true; _switchResult = Floats.toArray(((List<Float>) collection)); } } if (!_matched) { if (Objects.equal(componentType, double.class)) { _matched = true; _switchResult = Doubles.toArray(((List<Double>) collection)); } } if (!_matched) { _switchResult = Iterables.<Object>toArray(collection, ((Class<Object>) componentType)); } return _switchResult; }