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

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

Introduction

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

Prototype

@GwtCompatible(serializable = true)
public static <E> LinkedList<E> newLinkedList(Iterable<? extends E> elements) 

Source Link

Document

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

Usage

From source file:heros.fieldsens.Resolver.java

public void interest() {
    if (interest)
        return;/* w w  w. j  a  va  2 s  .c  om*/

    log("Interest given");
    interest = true;
    for (InterestCallback<Field, Fact, Stmt, Method> callback : Lists.newLinkedList(interestCallbacks)) {
        callback.interest(analyzer, this);
    }

    if (canBeResolvedEmpty)
        interestCallbacks = null;
}

From source file:io.wcm.caravan.io.jsontransform.element.JsonPathCreator.java

/**
 * Adds the given element to the bread crumb and returns the current JSON path.
 * @param element Current passed element
 * @return Current JSON path/*from w  w w  .j  a v a 2s .  c  o  m*/
 */
public JsonPath getJsonPathForElement(final JsonElement element) {
    if (element.isStartingElement()) {
        elements.add(element);
        return new JsonPath(Lists.newLinkedList(elements));
    } else if (element.isClosingElement()) {
        JsonPath path = new JsonPath(Lists.newLinkedList(elements));
        elements.pop();
        return path;
    }
    List<JsonElement> elementsPath = Lists.newLinkedList(elements);
    elementsPath.add(element);
    return new JsonPath(elementsPath);
}

From source file:org.gradle.api.internal.file.AntFileCollectionMatchingTaskBuilder.java

public Object addToAntBuilder(final Object node, final String childNodeName) {
    final DynamicObject dynamicObject = new BeanDynamicObject(node);

    final Iterable<DirectoryFileTree> existing = Lists
            .newLinkedList(FluentIterable.from(fileTrees).filter(new Predicate<DirectoryFileTree>() {
                @Override/* w  w w  . ja v a  2 s  . c o m*/
                public boolean apply(DirectoryFileTree input) {
                    return input.getDir().exists();
                }
            }));

    for (DirectoryFileTree fileTree : existing) {
        dynamicObject.invokeMethod(childNodeName, Collections.singletonMap("location", fileTree.getDir()));
    }

    dynamicObject.invokeMethod("or", new Closure<Void>(this) {
        public Object doCall(Object ignore) {
            for (final DirectoryFileTree fileTree : existing) {
                dynamicObject.invokeMethod("and", new Closure<Void>(this) {
                    public Object doCall(Object ignore) {
                        dynamicObject.invokeMethod("gradleBaseDirSelector",
                                Collections.singletonMap("baseDir", fileTree.getDir()));
                        fileTree.getPatterns().addToAntBuilder(node, null);
                        return null;
                    }
                });
            }
            return null;
        }
    });

    return node;
}

From source file:com.googlesource.gerrit.plugins.hooks.testutil.log.CollectionAppender.java

public Collection<LoggingEvent> getLoggedEvents() {
    return Lists.newLinkedList(events);
}

From source file:com.google.jstestdriver.model.RunData.java

public RunData recordResponse(ResponseStream responseStream) {
    final List<ResponseStream> newResponses = Lists.newLinkedList(responses);
    newResponses.add(responseStream);/* w  ww . j  ava2  s . c o  m*/
    return new RunData(newResponses, testCases, testCaseFactory);
}

From source file:com.continuuity.weave.internal.utils.Dependencies.java

/**
 * Finds the class dependencies of the given class.
 * @param classLoader ClassLoader for finding class bytecode.
 * @param classesToResolve Classes for looking for dependencies.
 * @param acceptor Predicate to accept a found class and its bytecode.
 * @throws IOException Thrown where there is error when loading in class bytecode.
 *///from   w  ww .jav  a  2 s  . c  om
public static void findClassDependencies(final ClassLoader classLoader, Set<String> acceptClassPath,
        Iterable<String> classesToResolve, final ClassAcceptor acceptor) throws IOException {

    final Set<String> seenClasses = Sets.newHashSet(classesToResolve);
    final Queue<String> classes = Lists.newLinkedList(classesToResolve);

    // Breadth-first-search classes dependencies.
    while (!classes.isEmpty()) {
        String className = classes.remove();
        URL classUrl = getClassURL(className, classLoader, acceptClassPath);
        if (classUrl == null) {
            continue;
        }

        // Open the stream for reading in class bytecode
        InputStream is = classUrl.openStream();
        try {
            byte[] bytecode = ByteStreams.toByteArray(is);

            // Call the accept to see if it accept the current class.
            if (!acceptor.accept(className, bytecode)) {
                continue;
            }

            // Visit the bytecode to lookup classes that the visiting class is depended on.
            new ClassReader(bytecode).accept(new DependencyClassVisitor(new DependencyAcceptor() {
                @Override
                public void accept(String className) {
                    // See if the class is accepted
                    if (seenClasses.add(className)) {
                        classes.add(className);
                    }
                }
            }), ClassReader.SKIP_DEBUG);
        } finally {
            is.close();
        }
    }
}

From source file:com.ericharlow.dnd.DragNDropAdapter.java

public DragNDropAdapter(Context context, int[] itemLayouts, IDictionaryService service) {
    init(context, itemLayouts, Lists.newLinkedList(service.allDictionaries()));
}

From source file:com.mycila.guice.ext.injection.FieldHandlerTypeListener.java

@Override
public <I> void hear(final TypeLiteral<I> type, TypeEncounter<I> encounter) {
    final Provider<? extends FieldHandler<A>> provider = encounter.getProvider(handlerClass);
    final List<Field> fields = Lists
            .newLinkedList(Reflect.findAllAnnotatedFields(type.getRawType(), annotationType));
    if (!fields.isEmpty()) {
        encounter.register(new InjectionListener<I>() {
            @Override/*w  ww . j  a va  2 s .  c om*/
            public void afterInjection(I injectee) {
                FieldHandler<A> handler = provider.get();
                for (Field field : fields)
                    handler.handle(type, injectee, field, field.getAnnotation(annotationType));
            }
        });
    }
}

From source file:org.apache.shindig.gadgets.rewrite.DefaultRequestRewriterRegistry.java

@Inject
public DefaultRequestRewriterRegistry(List<RequestRewriter> rewriters, GadgetHtmlParser htmlParser) {
    if (rewriters == null) {
        rewriters = Collections.emptyList();
    }//from w  w w . j  ava 2  s .  co m
    this.rewriters = Lists.newLinkedList(rewriters);
    this.htmlParser = htmlParser;
}

From source file:org.apache.shindig.gadgets.rewrite.DefaultResponseRewriterRegistry.java

@Inject
public DefaultResponseRewriterRegistry(List<ResponseRewriter> rewriters, GadgetHtmlParser htmlParser) {
    if (rewriters == null) {
        rewriters = Collections.emptyList();
    }/*www  .j  a  v  a2  s. co  m*/
    this.rewriters = Lists.newLinkedList(rewriters);
    this.htmlParser = htmlParser;
}