Example usage for com.google.common.collect Iterables toArray

List of usage examples for com.google.common.collect Iterables toArray

Introduction

In this page you can find the example usage for com.google.common.collect Iterables toArray.

Prototype

static <T> T[] toArray(Iterable<? extends T> iterable, T[] array) 

Source Link

Usage

From source file:org.geogit.cli.ArgumentTokenizer.java

public static String[] tokenize(String s) {
    Iterable<String> tokens = Splitter.on(new UnquotedSpace()).split(s);
    return Iterables.toArray(tokens, String.class);
}

From source file:org.opentestsystem.authoring.testspecbank.domain.EnumNamesAsString.java

public static <T extends Enum> String[] NAME_VALUES_AS_STRING(final T[] enumValues) {
    return Iterables.toArray(Iterables.transform(Lists.newArrayList(enumValues), new Function<T, String>() {
        @Override/*  ww  w.ja v  a  2 s.c o  m*/
        public String apply(final T enumIn) {
            if (enumIn != null) {
                return enumIn.name();
            }
            return "";
        }
    }), String.class);
}

From source file:zotmc.collect.forge.McCollect.java

public static Object adaptArgs(Class<Object> clz, Object... args) {
    return Iterables.toArray(Arrays.asList(args), clz);
}

From source file:org.apache.brooklyn.camp.brooklyn.spi.dsl.DslUtils.java

/** true iff none of the args are deferred / tasks */
public static boolean resolved(Iterable<Object> args) {
    return resolved(Iterables.toArray(args, Object.class));
}

From source file:eu.cloudwave.wp5.common.util.Splitters.java

public static String[] arrayOnComma(final String text) {
    return Iterables.toArray(onComma(text), String.class);
}

From source file:com.samskivert.depot.Ops.java

/**
 * Creates an AND expression with the supplied target expressions.
 *//*from ww  w .ja va 2s  . c om*/
public static FluentExp<Boolean> and(Iterable<? extends SQLExpression<?>> conditions) {
    return and(Iterables.toArray(conditions, SQLExpression.class));
}

From source file:com.tvl.util.SimpleElementImmutablesTestBase.java

protected final <T> Iterable<T> getIterableOf(Iterable<T> contents, Class<T> clazz) {
    T[] elements = Iterables.toArray(contents, clazz);
    return getIterableOf(elements);
}

From source file:com.googlecode.t7mp.configuration.Artifacts.java

public static AbstractArtifact fromCoordinates(String coordinates) {
    Iterable<String> splitted = Splitter.on(':').omitEmptyStrings().trimResults().split(coordinates);
    String[] strings = Iterables.toArray(splitted, String.class);
    if (strings.length < THREE || strings.length > FIVE) {
        throw new InvalidCoordinatesException(coordinates);
    } else {/*from   ww w.j a  v a 2s.c  o m*/
        String extension = "jar"; //DEFAULT
        String classifier = null; //DEFAULT
        String groupId = strings[ZERO];
        String artifactId = strings[ONE];
        String version = strings[strings.length - ONE];
        if (strings.length == FOUR) {
            extension = strings[TWO];
        }
        if (strings.length == FIVE) {
            classifier = strings[THREE];
        }
        return new DefaultArtifact(groupId, artifactId, version, classifier, extension);
    }
}

From source file:com.github.alexcojocaru.mojo.elasticsearch.v2.configuration.Artifacts.java

public static AbstractArtifact fromCoordinates(String coordinates) {
    Iterable<String> splitted = Splitter.on(':').omitEmptyStrings().trimResults().split(coordinates);
    String[] strings = Iterables.toArray(splitted, String.class);
    if (strings.length < THREE || strings.length > FIVE) {
        throw new InvalidCoordinatesException(coordinates);
    } else {/* w w  w  .  jav  a2 s  .c o  m*/
        String extension = "jar"; // DEFAULT
        String classifier = null; // DEFAULT
        String groupId = strings[ZERO];
        String artifactId = strings[ONE];
        String version = strings[strings.length - ONE];
        if (strings.length == FOUR) {
            extension = strings[TWO];
        }
        if (strings.length == FIVE) {
            classifier = strings[THREE];
        }
        return new DefaultArtifact(groupId, artifactId, version, classifier, extension);
    }
}

From source file:org.blip.workflowengine.transferobject.PathFinder.java

static List<Map.Entry<String[], Property>> find2(final PropertyNode propertyNode) {
    return PathFinder.find1(propertyNode).stream()
            .map(p -> new AbstractMap.SimpleEntry<>(Iterables.toArray(p.getKey(), String.class), p.getValue()))
            .collect(Collectors.toList());
}