Example usage for java.util Collection toArray

List of usage examples for java.util Collection toArray

Introduction

In this page you can find the example usage for java.util Collection toArray.

Prototype

default <T> T[] toArray(IntFunction<T[]> generator) 

Source Link

Document

Returns an array containing all of the elements in this collection, using the provided generator function to allocate the returned array.

Usage

From source file:logicProteinHypernetwork.networkStates.minimalNetworkStatesToNetworkStates.MinimalNetworkStatesToNetworkStates.java

/**
 * Transforms minimal network states to maximal combinations of not clashing minimal
 * network states in the form of network states.
 *
 * @param mns the minimal network states
 * @return the network states/*from  w  w w  .  j  a va 2  s. c o  m*/
 */
public Iterator<NetworkState> transform(Collection<MinimalNetworkState> mns) {
    MinimalNetworkState[] states = new MinimalNetworkState[mns.size()];
    mns.toArray(states);

    InstructionTree t = new InstructionTree(states);

    return t.getNetworkStateIterator();
}

From source file:com.palantir.docker.compose.execution.Docker.java

public void rm(Collection<String> containerNames) throws IOException, InterruptedException {
    rm(containerNames.toArray(new String[containerNames.size()]));
}

From source file:test.parsing.CollectingReaderEventListener.java

public ComponentDefinition[] getComponentDefinitions() {
    Collection<Object> collection = this.componentDefinitions.values();
    return collection.toArray(new ComponentDefinition[collection.size()]);
}

From source file:com.moisespsena.vraptor.modularvalidator.CategorizedMessagesImpl.java

public CategorizedMessagesImpl(final Collection<SimpleMessage> messages) {
    this(messages.toArray(new SimpleMessage[0]));
}

From source file:org.echocat.jomon.spring.application.JavaBasedApplicationContextGenerator.java

@Nonnull
protected ConfigurableApplicationContext generate(
        @Nonnull JavaBasedApplicationContextRequirement configuration) {
    final Collection<Class<?>> classes = configuration.getClasses();
    final Impl result = new Impl();
    result.register(classes.toArray(new Class[classes.size()]));
    result.setParent(configuration.getParentApplicationContext());
    result.setClassLoader(configuration.getClassLoader());
    return result;
}

From source file:com.google.code.guice.repository.configuration.RepositoriesGroupBuilder.java

public RepositoriesGroupBuilder withPackages(Collection<String> repositoriesPackages) {
    Assert.noNullElements(repositoriesPackages.toArray(new String[repositoriesPackages.size()]));
    this.repositoriesPackages.addAll(repositoriesPackages);
    return this;
}

From source file:ca.simplegames.micro.utils.StringUtils.java

/**
 * Copy the given Collection into a String array.
 * The Collection must contain String elements only.
 *
 * @param collection the Collection to copy
 * @return the String array (<code>null</code> if the passed-in
 *         Collection was <code>null</code>)
 */// w  w w.  j  a  va2 s .c  o  m
public static String[] toStringArray(Collection collection) {
    if (collection == null) {
        return null;
    }
    return (String[]) collection.toArray(new String[collection.size()]);
}

From source file:im.tym.wraop.impl.SpiBasedWrapperFactory.java

@Override
public void setInterfaces(Collection<Class<?>> wrappedInterfaces) {
    setInterfaces(wrappedInterfaces.toArray(EMPTY_CLASS_ARRAY));
}

From source file:de.tudarmstadt.ukp.dkpro.core.textnormalizer.transformation.DictionaryBasedTokenTransformer.java

@Override
public void process(JCas aInput, JCas aOutput) throws AnalysisEngineProcessException {
    // Processing must be done back-to-front to ensure that offsets for the next token being
    // processed remain valid. If this is done front-to-back, replacing a token with a
    // shorter or longer sequence would cause the offsets to shift.
    Collection<Token> tokens = select(aInput, Token.class);
    Token[] tokensArray = tokens.toArray(new Token[tokens.size()]);
    for (int i = tokensArray.length - 1; i >= 0; i--) {
        Token token = tokensArray[i];/*  ww  w. j  a  v a  2 s .co  m*/
        String curToken = token.getCoveredText();
        replace(token.getBegin(), token.getEnd(),
                mappings.containsKey(curToken) ? mappings.get(curToken) : curToken);
    }
}

From source file:dkpro.similarity.algorithms.structure.StopwordNGramContainmentMeasure.java

private List<String> retainStopwords(Collection<String> stringList) {
    List<String> inputTokens = Arrays.asList(stringList.toArray(new String[] {}));
    List<String> outputTokens = new ArrayList<String>();

    for (String token : inputTokens) {
        if (stopwords.contains(token))
            outputTokens.add(token);//from ww  w  .ja  v a2  s.  co m
    }

    return outputTokens;

}