List of usage examples for org.apache.commons.collections4 ListUtils unmodifiableList
public static <E> List<E> unmodifiableList(final List<? extends E> list)
From source file:com.github.rvesse.airline.help.suggester.GroupSuggester.java
@Override public Iterable<String> suggest() { List<String> suggestions = new ArrayList<String>(); for (CommandMetadata command : group.getCommands()) { suggestions.add(command.getName()); }/*from w ww. j a v a2s. com*/ for (OptionMetadata option : group.getOptions()) { suggestions.addAll(option.getOptions()); } return ListUtils.unmodifiableList(suggestions); }
From source file:com.github.rvesse.airline.help.suggester.CommandSuggester.java
@Override public Iterable<String> suggest() { List<String> suggestions = new ArrayList<String>(); for (OptionMetadata option : command.getCommandOptions()) { suggestions.addAll(option.getOptions()); }/*www . j a v a2s. c o m*/ if (command.getArguments() != null) { // Include arguments separator ParserMetadata<?> parserConfig = MetadataLoader.loadParser(command.getType()); suggestions.add(parserConfig.getArgumentsSeparator()); } return ListUtils.unmodifiableList(suggestions); }
From source file:com.github.rvesse.airline.help.suggester.GlobalSuggester.java
@Override public Iterable<String> suggest() { List<String> suggestions = new ArrayList<String>(); for (CommandGroupMetadata group : metadata.getCommandGroups()) { suggestions.add(group.getName()); }/* www .j av a 2 s.c o m*/ for (CommandMetadata command : metadata.getDefaultGroupCommands()) { suggestions.add(command.getName()); } for (OptionMetadata option : metadata.getOptions()) { suggestions.addAll(option.getOptions()); } return ListUtils.unmodifiableList(suggestions); }
From source file:com.github.rvesse.airline.Cli.java
public C parse(String... args) { return parse(ListUtils.unmodifiableList(AirlineUtils.arrayToList(args))); }
From source file:com.github.rvesse.airline.model.ArgumentsMetadata.java
public ArgumentsMetadata(Iterable<String> titles, String description, Iterable<ArgumentsRestriction> restrictions, Iterable<Field> path) { //@formatter:on if (titles == null) throw new NullPointerException("title cannot be null"); if (path == null) throw new NullPointerException("path cannot be null"); if (!path.iterator().hasNext()) throw new IllegalArgumentException("path cannot be empty"); this.titles = ListUtils.unmodifiableList(IteratorUtils.toList(titles.iterator())); this.description = description; this.restrictions = restrictions != null ? AirlineUtils.unmodifiableListCopy(restrictions) : Collections.<ArgumentsRestriction>emptyList(); this.accessors = SetUtils.unmodifiableSet(AirlineUtils.singletonSet(new Accessor(path))); }
From source file:com.github.rvesse.airline.Accessor.java
public Accessor(List<Field> path) { if (path == null) throw new NullPointerException("path is null"); if (path.size() == 0) throw new IllegalArgumentException("path is empty"); this.path = ListUtils.unmodifiableList(path); StringBuilder nameBuilder = new StringBuilder(); // Build the name for the accessor nameBuilder.append(this.path.get(0).getDeclaringClass().getSimpleName()); for (Field field : this.path) { nameBuilder.append('.').append(field.getName()); }//from w ww . ja v a 2s. c o m this.name = nameBuilder.toString(); Field field = this.path.get(this.path.size() - 1); multiValued = Collection.class.isAssignableFrom(field.getType()); javaType = getItemType(name, field.getGenericType()); }
From source file:com.github.rvesse.airline.parser.ParserUtil.java
@SuppressWarnings("unchecked") public static <T> T injectOptions(T commandInstance, Iterable<OptionMetadata> options, List<Pair<OptionMetadata, Object>> parsedOptions, ArgumentsMetadata arguments, Iterable<Object> parsedArguments, Iterable<Accessor> metadataInjection, Map<Class<?>, Object> bindings) { // inject options for (OptionMetadata option : options) { List<Object> values = new ArrayList<>(); for (Pair<OptionMetadata, Object> parsedOption : parsedOptions) { if (option.equals(parsedOption.getLeft())) values.add(parsedOption.getRight()); }/*ww w . j av a 2 s. c o m*/ if (values != null && !values.isEmpty()) { for (Accessor accessor : option.getAccessors()) { accessor.addValues(commandInstance, values); } } } // inject args if (arguments != null && parsedArguments != null) { for (Accessor accessor : arguments.getAccessors()) { accessor.addValues(commandInstance, parsedArguments); } } for (Accessor accessor : metadataInjection) { Object injectee = bindings.get(accessor.getJavaType()); if (injectee != null) { accessor.addValues(commandInstance, ListUtils.unmodifiableList(AirlineUtils.singletonList(injectee))); } } return commandInstance; }
From source file:com.github.sevntu.checkstyle.ordering.MethodOrder.java
public MethodOrder(Dependencies dependencies) { this.methods = MapUtils.unmodifiableMap(getAllMethods(dependencies)); this.initialOrdering = ListUtils.unmodifiableList(getInitialMethodOrdering(methods)); this.currentOrdering = this.initialOrdering; final Map<ResolvedCall, MethodInvocation> callsToInvocations = getAllInvocations(dependencies, methods); this.invocations = SetUtils.unmodifiableSet(new HashSet<>(callsToInvocations.values())); this.invocationNesting = MultiMapUtils .unmodifiableMultiValuedMap(getMethodInvocationsNesting(callsToInvocations)); }
From source file:com.github.rvesse.airline.utils.AirlineUtils.java
public static <T> List<T> unmodifiableListCopy(Collection<T> collection) { if (collection == null) return Collections.emptyList(); return ListUtils.unmodifiableList(new ArrayList<T>(collection)); }
From source file:com.civprod.writerstoolbox.NaturalLanguage.util.RegexStringTokenizer.java
public RegexStringTokenizer(List<Pattern> applyOrder, Map<Pattern, Pattern> ignoreMapping, Set<Pattern> removePatterns) { this.applyOrder = ListUtils.unmodifiableList(new ArrayList<>(applyOrder)); this.ignoreMapping = org.apache.commons.collections4.MapUtils.unmodifiableMap(new HashMap<>(ignoreMapping)); this.removePatterns = org.apache.commons.collections4.SetUtils .unmodifiableSet(new HashSet<>(removePatterns)); }