Example usage for org.apache.commons.collections4 ListUtils unmodifiableList

List of usage examples for org.apache.commons.collections4 ListUtils unmodifiableList

Introduction

In this page you can find the example usage for org.apache.commons.collections4 ListUtils unmodifiableList.

Prototype

public static <E> List<E> unmodifiableList(final List<? extends E> list) 

Source Link

Document

Returns an unmodifiable list backed by the given list.

Usage

From source file:de.tor.tribes.util.report.ReportManager.java

public List<ReportRule> getRules() {
    return ListUtils.unmodifiableList(rules);
}

From source file:com.github.rvesse.airline.builder.CliBuilder.java

@SuppressWarnings("unchecked")
public CliBuilder<C> withCommands(Class<? extends C> command, Class<? extends C>... moreCommands) {
    this.defaultCommandGroupCommands.add(command);
    this.defaultCommandGroupCommands.addAll(
            ListUtils.unmodifiableList(IteratorUtils.toList(IteratorUtils.arrayIterator(moreCommands))));
    return this;
}

From source file:com.github.rvesse.airline.utils.AirlineUtils.java

public static <T> List<T> unmodifiableListCopy(Iterable<T> iterable) {
    if (iterable == null)
        return Collections.emptyList();
    return ListUtils.unmodifiableList(IteratorUtils.toList(iterable.iterator()));
}

From source file:com.github.rvesse.airline.builder.CliBuilder.java

public CliBuilder<C> withCommands(Iterable<Class<? extends C>> commands) {
    this.defaultCommandGroupCommands
            .addAll(ListUtils.unmodifiableList(IteratorUtils.toList(commands.iterator())));
    return this;
}

From source file:com.github.rvesse.airline.utils.AirlineUtils.java

public static <T> List<T> unmodifiableListCopy(T[] array) {
    if (array == null)
        return Collections.emptyList();
    return ListUtils.unmodifiableList(arrayToList(array));
}

From source file:com.github.sevntu.checkstyle.ordering.MethodOrder.java

private MethodOrder(MethodOrder methodOrder, final List<Method> newMethodOrdering) {
    this.currentOrdering = ListUtils.unmodifiableList(newMethodOrdering);
    this.initialOrdering = methodOrder.initialOrdering;
    this.methods = methodOrder.methods;
    this.invocations = methodOrder.invocations;
    this.invocationNesting = methodOrder.invocationNesting;
}

From source file:com.github.rvesse.airline.model.CommandMetadata.java

public List<OptionMetadata> getAllOptions() {
    List<OptionMetadata> allOptions = new ArrayList<OptionMetadata>();
    allOptions.addAll(globalOptions);//from   w ww. j a  va  2s  . c  o  m
    allOptions.addAll(groupOptions);
    allOptions.addAll(commandOptions);
    return ListUtils.unmodifiableList(allOptions);
}

From source file:at.gv.egiz.pdfas.lib.impl.pdfbox.placeholder.SignaturePlaceholderExtractor.java

/**
 * Extracts all placeholders (with placeholder identifier
 * {@linkplain at.gv.egiz.pdfas.lib.impl.placeholder.PlaceholderExtractorConstants#QR_PLACEHOLDER_IDENTIFIER
 * QR_PLACEHOLDER_IDENTIFIER})./*from   w  ww  .jav a  2 s . c  o m*/
 * 
 * @param doc
 *            The pdfbox document object.
 * @return A (unmodifiable) list of signature place holders (never {@code null}).
 * @throws IOException
 *             Thrown in case of I/O error reading/parsing the pdf document.
 */
@SuppressWarnings("unchecked")
public static List<SignaturePlaceholderData> extract(PDDocument doc) throws IOException {
    Objects.requireNonNull(doc, "Pdfbox document must not be null.");

    SignaturePlaceholderExtractor extractor = new SignaturePlaceholderExtractor(QR_PLACEHOLDER_IDENTIFIER, // is ignored anyway
            PLACEHOLDER_MATCH_MODE_MODERATE // is ignored anyway
            , doc);

    int pageNr = 0;
    for (PDPage page : (Iterable<PDPage>) doc.getDocumentCatalog().getAllPages()) {
        extractor.setCurrentPage(++pageNr);
        PDStream contents;
        PDResources resources;
        if ((contents = page.getContents()) != null && contents.getStream() != null
                && (resources = page.findResources()) != null) {
            extractor.processStream(page, resources, contents.getStream());
        }
    }

    return ListUtils.unmodifiableList(new ArrayList<SignaturePlaceholderData>(extractor.placeholders));
}

From source file:com.github.rvesse.airline.help.common.AbstractUsageGenerator.java

/**
 * Converts the options into their synopsis representation for the usage
 * documentation//from  w  w  w  . jav a2s. c om
 * 
 * @param options
 *            Options
 * @return
 */
protected List<String> toSynopsisUsage(List<OptionMetadata> options) {
    List<String> synopsisOptions = new ArrayList<String>();
    for (OptionMetadata option : options) {
        if (option.isHidden() && !includeHidden)
            continue;
        synopsisOptions.add(toUsage(option));
    }
    return ListUtils.unmodifiableList(synopsisOptions);
}

From source file:com.github.rvesse.airline.builder.CliBuilder.java

@Override
public Cli<C> build() {
    CommandMetadata defaultCommandMetadata = null;
    List<CommandMetadata> allCommands = new ArrayList<CommandMetadata>();
    if (defaultCommand != null) {
        defaultCommandMetadata = MetadataLoader.loadCommand(defaultCommand);
    }/*from  ww w . j a v  a  2s .c om*/

    List<CommandMetadata> defaultCommandGroup = defaultCommandGroupCommands != null
            ? MetadataLoader.loadCommands(defaultCommandGroupCommands)
            : new ArrayList<CommandMetadata>();

    allCommands.addAll(defaultCommandGroup);
    if (defaultCommandMetadata != null)
        allCommands.add(defaultCommandMetadata);

    // Build groups
    List<CommandGroupMetadata> commandGroups;
    if (groups != null) {
        commandGroups = new ArrayList<CommandGroupMetadata>();
        for (GroupBuilder<C> groupBuilder : groups.values()) {
            commandGroups.add(groupBuilder.build());
        }
    } else {
        commandGroups = new ArrayList<>();
    }

    // Find all commands registered in groups and sub-groups, we use this to
    // check this is a valid CLI with at least 1 command
    for (CommandGroupMetadata group : commandGroups) {
        allCommands.addAll(group.getCommands());
        if (group.getDefaultCommand() != null)
            allCommands.add(group.getDefaultCommand());

        // Make sure to scan sub-groups
        Queue<CommandGroupMetadata> subGroups = new LinkedList<CommandGroupMetadata>();
        subGroups.addAll(group.getSubGroups());
        while (!subGroups.isEmpty()) {
            CommandGroupMetadata subGroup = subGroups.poll();
            allCommands.addAll(subGroup.getCommands());
            if (subGroup.getDefaultCommand() != null)
                allCommands.add(subGroup.getDefaultCommand());
            subGroups.addAll(subGroup.getSubGroups());
        }
    }

    // add commands to groups based on the value of groups in the @Command
    // annotations
    // rather than change the entire way metadata is loaded, I figured just
    // post-processing was an easier, yet uglier, way to go
    MetadataLoader.loadCommandsIntoGroupsByAnnotation(allCommands, commandGroups, defaultCommandGroup);

    // Build restrictions
    // Use defaults if none specified
    if (restrictions.size() == 0)
        withDefaultRestrictions();

    if (allCommands.size() == 0)
        throw new IllegalArgumentException("Must specify at least one command to create a CLI");

    // Build metadata objects
    GlobalMetadata<C> metadata = MetadataLoader.<C>loadGlobal(name, description, defaultCommandMetadata,
            ListUtils.unmodifiableList(defaultCommandGroup), ListUtils.unmodifiableList(commandGroups),
            ListUtils.unmodifiableList(restrictions), this.parserBuilder.build());

    return new Cli<C>(metadata);
}