Example usage for com.google.common.collect Sets newTreeSet

List of usage examples for com.google.common.collect Sets newTreeSet

Introduction

In this page you can find the example usage for com.google.common.collect Sets newTreeSet.

Prototype

public static <E extends Comparable> TreeSet<E> newTreeSet() 

Source Link

Document

Creates a mutable, empty TreeSet instance sorted by the natural sort ordering of its elements.

Usage

From source file:org.mycore.common.config.MCRRuntimeComponentDetector.java

private static SortedSet<MCRComponent> getConfiguredComponents() {
    try {//from ww w  .  ja  v  a 2 s .co m
        String underTesting = System.getProperty("MCRRuntimeComponentDetector.underTesting");
        Enumeration<URL> resources = MCRRuntimeComponentDetector.class.getClassLoader()
                .getResources("META-INF/MANIFEST.MF");
        if (!resources.hasMoreElements() && underTesting == null) {
            LOGGER.warn("Did not find any Manifests.");
            return Collections.emptySortedSet();
        }
        SortedSet<MCRComponent> components = Sets.newTreeSet();
        while (resources.hasMoreElements()) {
            URL manifestURL = resources.nextElement();
            try (InputStream manifestStream = manifestURL.openStream()) {
                Manifest manifest = new Manifest(manifestStream);
                MCRComponent component = buildComponent(manifest, manifestURL);

                if (component != null) {
                    components.add(component);
                }
            }
        }
        if (underTesting != null) {
            //support JUnit-Tests
            MCRComponent component = new MCRComponent(underTesting, new Manifest());
            components.add(component);
        }
        return components;
    } catch (IOException e) {
        LOGGER.warn("Error while detecting MyCoRe components", e);
        return Sets.newTreeSet();
    }
}

From source file:org.sonar.java.filters.SuppressWarningsFilter.java

private Collection<String> getWarningsByLine(Issue issue) {
    Integer line = issue.line();//  w w w  . j  av a  2 s .  c o  m
    String componentKey = issue.componentKey();
    if (line != null && suppressWarningsLinesByResource.containsKey(componentKey)) {
        return suppressWarningsLinesByResource.get(componentKey).get(line);
    }
    return Sets.newTreeSet();
}

From source file:org.ldp4j.application.engine.context.ContentPreferences.java

private ContentPreferences() {
    this.include = Sets.newTreeSet();
    this.omit = Sets.newTreeSet();
}

From source file:org.jclouds.atmosonline.saas.functions.ParseUserMetadataFromHeaders.java

private Set<String> getTags(String meta) {
    Set<String> tags = Sets.newTreeSet();
    String[] metas = meta.split(", ");
    for (String entry : metas) {
        tags.add(entry);/*from ww  w.ja va2s . co  m*/
    }
    return tags;
}

From source file:com.google.devtools.j2objc.gen.ObjectiveCHeaderGenerator.java

protected void generateFileHeader() {
    printf("#ifndef %s_H\n", varPrefix);
    printf("#define %s_H\n", varPrefix);
    pushIgnoreDeprecatedDeclarationsPragma();

    Set<String> seenTypes = Sets.newHashSet();
    Set<String> includeFiles = Sets.newTreeSet();
    Set<Import> forwardDeclarations = Sets.newHashSet();

    includeFiles.add("J2ObjC_header.h");

    for (GeneratedType type : getOrderedTypes()) {
        String name = type.getTypeName();
        if (!type.isPrivate()) {
            seenTypes.add(name);/*from   w w  w  . j av a 2 s . c  o  m*/
        }
        for (Import imp : type.getHeaderIncludes()) {
            if (!isLocalType(imp.getTypeName())) {
                includeFiles.add(imp.getImportFileName());
            }
        }
        for (Import imp : type.getHeaderForwardDeclarations()) {
            // Filter out any declarations that are resolved by an include.
            if (!seenTypes.contains(imp.getTypeName()) && !includeFiles.contains(imp.getImportFileName())) {
                forwardDeclarations.add(imp);
            }
        }
    }

    // Print collected includes.
    newline();
    for (String header : includeFiles) {
        printf("#include \"%s\"\n", header);
    }
    printForwardDeclarations(forwardDeclarations);

    // Print OCNI blocks
    for (String code : getGenerationUnit().getNativeHeaderBlocks()) {
        print(code);
    }
}

From source file:org.jclouds.blobstore.strategy.internal.ListBlobMetadataInContainer.java

public SortedSet<? extends BlobMetadata> execute(String container, ListContainerOptions options) {
    try {/*from  w  ww .ja  v  a  2 s  .  com*/
        ListResponse<? extends ResourceMetadata> resources = connection.list(container, options)
                .get(requestTimeoutMilliseconds, TimeUnit.MILLISECONDS);
        SortedSet<BlobMetadata> blobM = Sets.newTreeSet();
        for (ResourceMetadata from : resources) {
            if (from.getType() == ResourceType.BLOB)
                blobM.add((BlobMetadata) from);
        }
        return blobM;
    } catch (Exception e) {
        Utils.<BlobRuntimeException>rethrowIfRuntimeOrSameType(e);
        throw new BlobRuntimeException("Error getting resource metadata in container: " + container, e);
    }
}

From source file:com.netflix.ice.processor.ReadWriteData.java

public Collection<TagGroup> getTagGroups() {
    Set<TagGroup> keys = Sets.newTreeSet();

    for (Map<TagGroup, Double> map : data) {
        keys.addAll(map.keySet());/*from w w  w  .j  a  va2s  . co  m*/
    }

    return keys;
}

From source file:org.lmnl.util.Partitioning.java

public SortedSet<Range> apply(Iterable<Annotation> from) {
    SortedSet<Integer> offsets = Sets.newTreeSet();

    if (filterPredicate != null) {
        from = Iterables.filter(from, filterPredicate);
    }//ww w . j a  va 2 s . com

    for (Annotation a : from) {
        offsets.add(a.getRange().getStart());
        offsets.add(a.getRange().getEnd());
    }

    SortedSet<Range> partition = new TreeSet<Range>();
    int start = -1;
    for (int end : offsets) {
        if (start >= 0) {
            partition.add(new Range(start, end));
        }
        start = end;
    }
    return partition;
}

From source file:sc.calendar.dataSource.PollCalendar.java

Set<CalendarEvent> getEvents(String id) {

    Set<CalendarEvent> eventsOut = Sets.newTreeSet();
    try {//from  w  ww  .  j  a  v a  2  s.co m
        com.google.api.services.calendar.Calendar.Events.List query = client.events().list(id);

        String date = SCalConstants.rfc3339
                .format(new Date(System.currentTimeMillis() - SCalConstants.BUFFER_PERIOD_MS));
        query.setTimeMin(date);
        Events events = query.execute();

        if (events.getItems() != null) {
            for (Event e : events.getItems()) {

                DateTime start = e.getStart().getDateTime();
                if (start == null)
                    try {
                        start = new DateTime(SCalConstants.simpleDateFormat.parse(e.getStart().getDate()));
                    } catch (ParseException e1) {
                        Log.e(this.getClass().getName(), e1.getMessage(), e1);
                    }

                DateTime end = e.getEnd().getDateTime();
                if (end == null)
                    try {
                        end = new DateTime(SCalConstants.simpleDateFormat.parse(e.getEnd().getDate()));
                    } catch (ParseException e1) {
                        Log.e(this.getClass().getName(), e1.getMessage(), e1);
                    }

                CalendarEvent ce = new CalendarEvent(start.getValue(), end.getValue(), e.getSummary(),
                        e.getId(), false, id);

                eventsOut.add(ce);
            }
        }
    } catch (IOException e) {
        Log.e(this.getClass().getName(), e.getMessage(), e);
    }
    return eventsOut;
}

From source file:nz.org.nesi.goji.model.commands.LsCommand.java

@Override
protected void processResult() {

    try {//  ww w  .  jav a  2 s  .c o  m

        String path = extractFromResults("path");
        putOutput(PARAM.PATH, path);
        String endpoint = extractFromResults("endpoint");
        putOutput(PARAM.ENDPOINT_NAME, endpoint);
        String group = extractFromResults("DATA", "group");

        files = Sets.newTreeSet();

        JSONObject jsonO = result.getJSONObject(0);
        if (jsonO != null) {
            JSONArray dataArr = jsonO.getJSONArray("DATA");

            for (int i = 0; i < dataArr.length(); i++) {
                JSONObject o = dataArr.getJSONObject(i);
                GFile f = new GFile(o);
                files.add(f);
            }
        }

    } catch (Exception e) {
        e.printStackTrace();
    }

}