int length = existing == null ? 0 : Array.getLength(existing); Class<?> type = argSpec.auxiliaryTypes()[0]; List<Object> converted = consumeArguments(argSpec, lookBehind, arity, args, type, argDescription); List<Object> newValues = new ArrayList<Object>(); if (initialized.contains(argSpec)) { // existing values are default values if initialized does NOT contain argsSpec
@SuppressWarnings("unchecked") private int applyValuesToCollectionField(ArgSpec argSpec, LookBehind lookBehind, Range arity, Stack<String> args, Set<ArgSpec> initialized, String argDescription) throws Exception { Collection<Object> collection = (Collection<Object>) argSpec.getValue(); Class<?> type = argSpec.auxiliaryTypes()[0]; List<Object> converted = consumeArguments(argSpec, lookBehind, arity, args, type, argDescription); if (collection == null || (!collection.isEmpty() && !initialized.contains(argSpec))) { tracer.debug("Initializing binding for %s with empty %s%n", optionDescription("", argSpec, 0), argSpec.type().getSimpleName()); collection = createCollection(argSpec.type()); // collection type argSpec.setValue(collection); } initialized.add(argSpec); for (Object element : converted) { if (element instanceof Collection<?>) { collection.addAll((Collection<?>) element); } else { collection.add(element); } } parseResult.add(argSpec, position); argSpec.setValue(collection); return converted.size(); }
int length = existing == null ? 0 : Array.getLength(existing); Class<?> type = argSpec.auxiliaryTypes()[0]; List<Object> converted = consumeArguments(argSpec, lookBehind, arity, args, type, argDescription); List<Object> newValues = new ArrayList<Object>(); if (initialized.contains(argSpec)) { // existing values are default values if initialized does NOT contain argsSpec
@SuppressWarnings("unchecked") private int applyValuesToCollectionField(ArgSpec argSpec, LookBehind lookBehind, Range arity, Stack<String> args, Set<ArgSpec> initialized, String argDescription) throws Exception { Collection<Object> collection = (Collection<Object>) argSpec.getValue(); Class<?> type = argSpec.auxiliaryTypes()[0]; List<Object> converted = consumeArguments(argSpec, lookBehind, arity, args, type, argDescription); if (collection == null || (!collection.isEmpty() && !initialized.contains(argSpec))) { tracer.debug("Initializing binding for %s with empty %s%n", optionDescription("", argSpec, 0), argSpec.type().getSimpleName()); collection = createCollection(argSpec.type()); // collection type argSpec.setValue(collection); } initialized.add(argSpec); for (Object element : converted) { if (element instanceof Collection<?>) { collection.addAll((Collection<?>) element); } else { collection.add(element); } } parseResult.add(argSpec, position); argSpec.setValue(collection); return converted.size(); }