Example usage for com.google.common.collect Lists newArrayList

List of usage examples for com.google.common.collect Lists newArrayList

Introduction

In this page you can find the example usage for com.google.common.collect Lists newArrayList.

Prototype

@GwtCompatible(serializable = true)
public static <E> ArrayList<E> newArrayList(Iterator<? extends E> elements) 

Source Link

Document

Creates a mutable ArrayList instance containing the given elements; a very thin shortcut for creating an empty list and then calling Iterators#addAll .

Usage

From source file:org.eclipse.sw360.exporter.ExporterHelper.java

static List<String> addSubheadersWithPrefixesAsNeeded(List<String> headers, List<String> subheaders,
        String prefix) {//from  w  w  w . j  a  v a2 s.co  m
    List<String> prefixedSubheaders = subheaders.stream().map(h -> headers.contains(h) ? prefix + h : h)
            .collect(Collectors.toList());
    List<String> copy = Lists.newArrayList(headers);
    copy.addAll(prefixedSubheaders);
    return copy;
}

From source file:io.pravega.controller.store.stream.tables.RetentionRecord.java

public static RetentionRecord addStreamCutIfLatest(RetentionRecord record, StreamCutRecord cut) {
    List<StreamCutRecord> list = Lists.newArrayList(record.streamCuts);

    // add only if cut.recordingTime is newer than any previous cut
    if (list.stream().noneMatch(x -> x.getRecordingTime() >= cut.getRecordingTime())) {
        list.add(cut);// www  .java  2 s.com
    }

    return new RetentionRecord(list);
}

From source file:org.dspace.xoai.data.DSpaceItem.java

private static List<Element> filter(List<Element> input, String name) {
    return Lists.newArrayList(Collections2.filter(input, new MetadataNamePredicate(name)));
}

From source file:grkvlt.Ec2CleanUp.java

/**
 * Command-line entry point.// w ww . j a  va  2 s.c  o m
 *
 * See {@code README.md} for usage example.
 */
public static void main(String... argv) throws Exception {
    String regionParam = AWS_EUROPE;
    String regexpParam = JCLOUDS_NAME_REGEXP;
    boolean checkParam = Boolean.FALSE;

    // Set check, region and regular expression parameters from command line arguments
    List<String> parameters = Lists.newArrayList(argv);
    if (parameters.remove("check")) {
        checkParam = Boolean.TRUE;
    }
    if (parameters.size() > 0)
        regionParam = parameters.get(0);
    if (parameters.size() > 1)
        regexpParam = parameters.get(1);
    LOG.info("{} SecurityGroups, KeyPairs and Volumes in aws-ec2:{} matching '{}'",
            new Object[] { checkParam ? "Checking" : "Cleaning", regionParam, regexpParam });

    // Set EC2 identity and credential from system properties
    String identityValue = System.getProperty(IDENTITY_PROPERTY);
    String credentialValue = System.getProperty(CREDENTIAL_PROPERTY);

    Preconditions.checkNotNull(identityValue,
            String.format("The %s property must be set to your EC2 access key", IDENTITY_PROPERTY));
    Preconditions.checkNotNull(credentialValue,
            String.format("The %s property must be set to your EC2 secret key", CREDENTIAL_PROPERTY));

    // Initialise and then execute the cleanUp method
    Ec2CleanUp cleaner = new Ec2CleanUp(regionParam, regexpParam, identityValue, credentialValue, checkParam);
    cleaner.cleanUp();
}

From source file:ee.ellytr.command.util.Collections.java

public static <T> List<T> getIntersection(List<T> list1, List<T> list2) {
    List<T> intersection = Lists.newArrayList(list1);
    intersection.retainAll(list2);/*from   ww w .  j a va2  s. co  m*/
    return intersection;
}

From source file:org.jmingo.util.ReflectionUtils.java

public static List<Field> getFields(Class<?> type) {
    return Lists.newArrayList(type.getDeclaredFields());
}

From source file:org.quickgeo.PlaceFactory.java

public static Place fromLine(String line) {
    Iterable<String> iter = SPLITTER.split(line);

    String[] items = Lists.newArrayList(iter).toArray(new String[0]);

    Integer accuracy = null;//from w  ww. jav  a2s. com

    if (items[11] != null && !items[11].isEmpty()) {
        accuracy = Integer.parseInt(items[11]);
    }

    return new Place(items[0], items[1], items[2], items[3], items[4], items[5], items[6], items[7], items[8],
            Double.parseDouble(items[9]), Double.parseDouble(items[10]), accuracy);
}

From source file:io.macgyver.core.util.Neo4jUtil.java

public static ObjectNode scrubNonCompliantNeo4jAttributes(ObjectNode t) {
    ObjectNode n = t.deepCopy();/*w  w  w.jav  a  2s  .co m*/

    for (String name : Lists.newArrayList(n.fieldNames())) {

        JsonNode val = n.get(name);
        if (val == null) {
            // shouldn't happen
        } else if (val.isValueNode()) {
            // simple value nodes are OK
        } else if (val.isArray()) {
            ArrayNode an = (ArrayNode) val;
            an.forEach(cn -> {
                if (cn != null && cn.isContainerNode()) {
                    n.remove(name);
                }
                // note that types of the array have to be consistent.  Neo4j does not support [ 123, "abc" ]
                // But let that be the responsibility of the caller
            });

            // neo4j does not support nested objects
        } else if (val.isObject()) {
            n.remove(name);
        } else if (val.isNull()) {

        } else if (val.isMissingNode()) {
            n.remove(name);
        }

    }

    return n;
}

From source file:com.cloudera.exhibit.core.simple.SimpleObs.java

public static SimpleObs of(ObsDescriptor desc, Object... args) {
    return new SimpleObs(desc, Lists.newArrayList(args));
}

From source file:edu.bsu.storygame.editor.model.Story.java

public static Story emptyStory() {
    return new Story("", Lists.newArrayList(new SkillTrigger("No skill", Conclusion.emptyConclusion())));
}