List of usage examples for com.google.common.primitives Chars asList
public static List<Character> asList(char... backingArray)
From source file:org.jclouds.util.Strings2.java
/** * Web browsers do not always handle '+' characters well, use the well-supported '%20' instead. *//*w ww. j a va2 s .c om*/ public static String urlEncode(String in, char... skipEncode) { return urlEncode(in, Chars.asList(skipEncode)); }
From source file:org.truth0.subjects.PrimitiveCharArraySubject.java
@Override protected List<Character> listRepresentation() { return Chars.asList(getSubject()); }
From source file:com.example.securelogin.app.common.filter.InputValidationFilter.java
public InputValidationFilter(char[] prohibitedChars, char[] prohibitedCharsForFileName) { this.prohibitedChars = Chars.asList(prohibitedChars); this.prohibitedCharsForFileName = Chars.asList(prohibitedCharsForFileName); }
From source file:org.truth0.subjects.PrimitiveCharArraySubject.java
/** * A proposition that the provided Object[] is an array of the same length and type, and * contains elements such that each element in {@code expected} is equal to each element * in the subject, and in the same position. *///www .ja v a2 s.c o m @Override public void isEqualTo(Object expected) { char[] actual = getSubject(); if (actual == expected) { return; // short-cut. } try { char[] expectedArray = (char[]) expected; if (!Arrays.equals(actual, expectedArray)) { fail("is equal to", Chars.asList(expectedArray)); } } catch (ClassCastException e) { failWithBadType(expected); } }
From source file:com.wmw.math.systems.SystemConvertor.java
private void checkNoInvalidDigit(String base1Digits) { List<Character> inputChars = Chars.asList(base1Digits.toCharArray()); if (newRubyArray(inputChars).minus(base1).size() > 0) throw new IllegalArgumentException("Input contains invalid digit."); }
From source file:org.truth0.subjects.PrimitiveCharArraySubject.java
@Override public void isNotEqualTo(Object expected) { char[] actual = getSubject(); try {//from www.ja va 2 s. co m char[] expectedArray = (char[]) expected; if (actual == expected || Arrays.equals(actual, expectedArray)) { failWithRawMessage("%s unexpectedly equal to %s.", getDisplaySubject(), Chars.asList(expectedArray)); } } catch (ClassCastException ignored) { } }
From source file:tv.dyndns.kishibe.qmaclone.client.creation.validater.Validator.java
private static Set<Character> toSet(String s) { return ImmutableSet.copyOf(Chars.asList(s.toCharArray())); }
From source file:com.example.basic.PublicMethodInvoker.java
public String invokeAllPublicArrayMethods(AllAccessMethods allAccessMethods) { StringBuilder result = new StringBuilder(); result.append(Joiner.on(':').join(allAccessMethods.publicStringArrayMethod(new String[] { "invoker" }))); result.append('-'); result.append(Joiner.on(':').join(Ints.asList(allAccessMethods.publicIntArrayMethod(new int[] { 5 })))); result.append('-'); result.append(Joiner.on(':').join(Longs.asList(allAccessMethods.publicLongArrayMethod(new long[] { 3 })))); result.append('-'); result.append(//from w w w . j a va 2 s. c om Joiner.on(':').join(Chars.asList(allAccessMethods.publicCharArrayMethod(new char[] { 'a' })))); result.append('-'); result.append(Joiner.on(':') .join(Booleans.asList(allAccessMethods.publicBooleanArrayMethod(new boolean[] { false })))); result.append('-'); result.append( Joiner.on(':').join(Floats.asList(allAccessMethods.publicFloatArrayMethod(new float[] { 12f })))); result.append('-'); result.append(Joiner.on(':') .join(Doubles.asList(allAccessMethods.publicDoubleArrayMethod(new double[] { 56d })))); result.append('-'); result.append(myField); allAccessMethods.voidMethod(); return result.toString(); }
From source file:com.sk89q.intake.parametric.MethodCallable.java
static MethodCallable create(ParametricBuilder builder, Object object, Method method) throws IllegalParameterException { checkNotNull(builder, "builder"); checkNotNull(object, "object"); checkNotNull(method, "method"); Set<Annotation> commandAnnotations = ImmutableSet.copyOf(method.getAnnotations()); Command definition = method.getAnnotation(Command.class); checkNotNull(definition, "Method lacks a @Command annotation"); boolean ignoreUnusedFlags = definition.anyFlags(); Set<Character> unusedFlags = ImmutableSet.copyOf(Chars.asList(definition.flags().toCharArray())); Annotation[][] annotations = method.getParameterAnnotations(); Type[] types = method.getGenericParameterTypes(); ArgumentParser.Builder parserBuilder = new ArgumentParser.Builder(builder.getInjector()); for (int i = 0; i < types.length; i++) { parserBuilder.addParameter(types[i], Arrays.asList(annotations[i])); }/*from w ww.j av a 2 s . c om*/ ArgumentParser parser = parserBuilder.build(); ImmutableDescription.Builder descBuilder = new ImmutableDescription.Builder() .setParameters(parser.getUserParameters()) .setShortDescription(!definition.desc().isEmpty() ? definition.desc() : null) .setHelp(!definition.help().isEmpty() ? definition.help() : null) .setUsageOverride(!definition.usage().isEmpty() ? definition.usage() : null); Require permHint = method.getAnnotation(Require.class); List<String> permissions = null; if (permHint != null) { descBuilder.setPermissions(Arrays.asList(permHint.value())); permissions = Arrays.asList(permHint.value()); } for (InvokeListener listener : builder.getInvokeListeners()) { listener.updateDescription(commandAnnotations, parser, descBuilder); } Description description = descBuilder.build(); MethodCallable callable = new MethodCallable(builder, parser, object, method, description, permissions); callable.setCommandAnnotations(ImmutableList.copyOf(method.getAnnotations())); callable.setIgnoreUnusedFlags(ignoreUnusedFlags); callable.setUnusedFlags(unusedFlags); return callable; }
From source file:ca.ualberta.physics.cssdp.model.Mnemonic.java
private void validate(String value) { List<Character> characterList = Chars.asList(value.toCharArray()); Set<Character> characterSet = new HashSet<Character>(characterList); Set<Character> shouldBeEmpty = Sets.difference(characterSet, allowedChars); if (shouldBeEmpty.size() > 0) { throw new IllegalArgumentException("Mnemonic contains invalid characters: " + shouldBeEmpty + " \n Only these are allowed: " + allowedChars); }//from w w w .j a va 2 s .c o m if (value.length() > 20) { throw new IllegalArgumentException("Mnemonic length is too long, max is 20 characters"); } }