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() 

Source Link

Document

Creates a mutable, empty LinkedList instance (for Java 6 and earlier).

Usage

From source file:com.cloudera.oryx.common.log.MemoryHandler.java

public MemoryHandler() {
    logLines = Lists.newLinkedList();
    setFormatter(new SimpleFormatter());
    setLevel(Level.FINE);
}

From source file:ru.frostman.web.classloading.ClassPathUtil.java

public static List<ClassFile> findClassFiles(List<String> packageNames) {
    final List<ClassFile> classes = Lists.newLinkedList();
    final Set<String> classNames = Sets.newHashSet();

    for (String packageName : packageNames) {
        try {/*  w  w  w.  ja v a2s  .co  m*/
            String realPath = packageName.replace('.', '/');
            Enumeration<URL> resources = Thread.currentThread().getContextClassLoader().getResources(realPath);
            while (resources.hasMoreElements()) {
                URL resource = resources.nextElement();
                Preconditions.checkNotNull(resource, "no resource for: {}", packageName);
                String filePath = resource.getFile();

                File dir = new File(filePath);
                if (dir.exists()) {
                    scanDirectory(packageName, dir, classes, classNames);
                } else if ((filePath.indexOf("!") > 0) && (filePath.indexOf(".jar") > 0)) {
                    String jarPath = filePath.substring(0, filePath.indexOf("!"))
                            .substring(filePath.indexOf(":") + 1);
                    // WINDOWS HACK
                    if (jarPath.contains(":")) {
                        jarPath = jarPath.substring(1);
                    }

                    scanJarFile(packageName, new File(jarPath), classes, classNames);
                }
            }
        } catch (IOException e) {
            log.warn("Error while scanning for class files in package: {}", e);
        }
    }

    return classes;
}

From source file:org.apache.kylin.tool.metrics.systemcube.KylinTableCreator.java

public static TableDesc generateKylinTableForMetricsQuery(KylinConfig kylinConfig, SinkTool sinkTool) {
    List<Pair<String, String>> columns = Lists.newLinkedList();
    columns.addAll(HiveTableCreator.getHiveColumnsForMetricsQuery());
    columns.addAll(HiveTableCreator.getPartitionKVsForHiveTable());
    return generateKylinTable(sinkTool, kylinConfig.getKylinMetricsSubjectQuery(), columns);
}

From source file:io.rebolt.http.utils.HeaderParser.java

public HeaderParser(final String headerString) {
    requireNonNull(headerString);//  www. j  a v a 2  s  .  c  o m
    this.origin = headerString;
    this.mediaTypes = Lists.newLinkedList();
    StringUtil.split(',', headerString).forEach(entry -> {
        try {
            mediaTypes.add(MediaType.parse(entry));
        } catch (Exception ignored) {
        }
    });
}

From source file:org.artifactory.api.callhome.CallHomeRequest.java

/**
 * Adds in/*from  w  ww .j  a  v a 2s . co m*/
 *
 * @param callHomeFeature
 */
public void addCallHomeFeature(FeatureGroup callHomeFeature) {
    if (featureGroups == null)
        featureGroups = Lists.newLinkedList();
    featureGroups.add(callHomeFeature);
}

From source file:org.metaborg.intellij.idea.extensions.IntelliJPluginLoader.java

@Override
public Collection<Module> modules() throws MetaborgException {
    try {//from w  ww . j a v  a  2  s.c o m
        final Iterable<T> plugins = getPlugins();
        final Collection<Module> modules = Lists.newLinkedList();
        for (final T plugin : plugins) {
            Iterables.addAll(modules, plugin.modules());
        }
        return modules;
    } catch (final Exception e) {
        throw new MetaborgException(
                "Unhandled exception while loading module plugins with IntelliJ's IntelliJPluginLoader.", e);
    }
}

From source file:integration.simpleusages.InSameContext.java

@Override
public List<Usage> getTrainingData() {
    List<Usage> usages = Lists.newLinkedList();

    for (int i = 0; i < 2; i++) {
        usages.add(createUsageWithB());//from  w ww .  java2  s  .  c o m
    }

    for (int i = 0; i < 1; i++) {
        usages.add(createUsageWithC());
    }

    return usages;
}

From source file:co.cask.cdap.common.collect.LastNCollector.java

public LastNCollector(int n) {
    Preconditions.checkArgument(n > 0, "n must be greater than 0");
    this.maxCount = n;
    this.elements = Lists.newLinkedList();
}

From source file:com.davidbracewell.ml.sequence.indexers.SinglePassIndexer.java

@Override
public List<List<Instance>> index(List<Sequence<V>> data) {
    List<List<Instance>> instances = Lists.newLinkedList();
    for (Sequence<V> sequence : data) {
        List<Instance> list = Lists.newArrayListWithExpectedSize(sequence.length());
        for (int i = 0; i < sequence.length(); i++) {
            Instance instance = sequence.generateInstance(i, sequence.getLabels());
            instance.trimToSize();/* ww  w. j a  va2s  .  c  o  m*/
            list.add(instance);
        }
        instances.add(list);
    }
    return instances;
}

From source file:com.twitter.hdfsdu.TreeSizeByPathServlet.java

@Override
public Iterable<String> getLines(HttpServletRequest request) {
    String paramPath = request.getParameter("path");
    if (paramPath == null) {
        paramPath = "/";
    }//from www .  ja v a2  s .c  om
    List<String> lines = Lists.newLinkedList();
    List<NodeData> elems = Lists.newArrayList();
    Integer paramDepth = request.getParameter("depth") == null ? 2
            : Integer.parseInt(request.getParameter("depth"));

    try {
        ResultSet resultSet = getSizeByPath(request);
        NodeData data;
        while (resultSet.next()) {
            data = new NodeData();
            data.fileSize = resultSet.getString("size_in_bytes");
            data.nChildren = resultSet.getLong("file_count");
            data.path = resultSet.getString("path");
            data.leaf = resultSet.getBoolean("leaf");
            elems.add(data);
        }
        JSONObject jsonObject = DataTransformer.getJSONTree(paramPath, paramDepth, elems);

        String ans = null;
        if (jsonObject != null) {
            ans = jsonObject.toJSONString();
        }

        if (ans == null) {
            lines.add("{ \"children\": [] }");
        } else {
            lines.add(ans);
        }
    } catch (SQLException e) {
        e.printStackTrace();
    }
    return lines;
}