private List<String> getTokens(final Method method, final String value) { final Separator separator = method.getAnnotation(Separator.class); if (value == null || value.isEmpty()) { return ImmutableList.of(); } else { return ImmutableList.copyOf(value.split(separator == null ? Separator.DEFAULT : separator.value())); } }
private List<String> getTokens(final Method method, final String value) { final Separator separator = method.getAnnotation(Separator.class); if (value == null || value.isEmpty()) { return ImmutableList.of(); } else { return ImmutableList.copyOf(value.split(separator == null ? Separator.DEFAULT : separator.value())); } }
private Object coerceArray(Class<?> elemType, String value, Separator separator) { if (value == null) { return null; } else if (value.length() == 0) { return Array.newInstance(elemType, 0); } else { String[] tokens = value.split(separator == null ? Separator.DEFAULT : separator.value()); Object targetArray = Array.newInstance(elemType, tokens.length); for (int idx = 0; idx < tokens.length; idx++) { Array.set(targetArray, idx, coerce(elemType, tokens[idx])); } return targetArray; } }
private Object coerceArray(Class<?> elemType, String value, Separator separator) { if (value == null) { return null; } else if (value.length() == 0) { return Array.newInstance(elemType, 0); } else { String[] tokens = value.split(separator == null ? Separator.DEFAULT : separator.value()); Object targetArray = Array.newInstance(elemType, tokens.length); for (int idx = 0; idx < tokens.length; idx++) { Array.set(targetArray, idx, coerce(elemType, tokens[idx])); } return targetArray; } }
for (String token : value.split(separator == null ? Separator.DEFAULT : separator.value())) { result.add(coerce(elemType, token));
for (String token : value.split(separator == null ? Separator.DEFAULT : separator.value())) { result.add(coerce(elemType, token));