Example usage for com.google.common.collect ImmutableSortedSet naturalOrder

List of usage examples for com.google.common.collect ImmutableSortedSet naturalOrder

Introduction

In this page you can find the example usage for com.google.common.collect ImmutableSortedSet naturalOrder.

Prototype

public static <E extends Comparable<?>> Builder<E> naturalOrder() 

Source Link

Usage

From source file:com.facebook.buck.versions.VersionPropagatorBuilder.java

public VersionPropagatorBuilder setDeps(String... deps) {
    ImmutableSortedSet.Builder<BuildTarget> builder = ImmutableSortedSet.naturalOrder();
    for (String dep : deps) {
        builder.add(BuildTargetFactory.newInstance(dep));
    }// w  w  w .  j  a v a  2 s.  com
    return setDeps(builder.build());
}

From source file:com.ibm.common.geojson.BoundingBox.java

protected static BoundingBox calculateBoundingBoxLineStrings(Iterable<LineString> lineStrings) {
    ImmutableSortedSet.Builder<Float> xset = ImmutableSortedSet.naturalOrder();
    ImmutableSortedSet.Builder<Float> yset = ImmutableSortedSet.naturalOrder();
    ImmutableSortedSet.Builder<Float> zset = ImmutableSortedSet.naturalOrder();
    for (LineString ls : lineStrings) {
        for (Position p : ls) {
            xset.add(p.northing());//www .  jav  a 2 s  .  c  o  m
            yset.add(p.easting());
            if (p.hasAltitude())
                zset.add(p.altitude());
        }
    }
    return buildBoundingBox(xset.build(), yset.build(), zset.build());
}

From source file:com.facebook.buck.cxx.CxxCompilationDatabase.java

public static CxxCompilationDatabase createCompilationDatabase(BuildRuleParams params,
        SourcePathResolver pathResolver, Iterable<CxxPreprocessAndCompile> compileAndPreprocessRules) {
    ImmutableSortedSet.Builder<BuildRule> deps = ImmutableSortedSet.naturalOrder();
    ImmutableSortedSet.Builder<CxxPreprocessAndCompile> compileRules = ImmutableSortedSet.naturalOrder();
    for (CxxPreprocessAndCompile compileRule : compileAndPreprocessRules) {
        compileRules.add(compileRule);/*from   ww  w .  j  a va  2  s . c o  m*/
        deps.addAll(compileRule.getDeps());
    }

    return new CxxCompilationDatabase(
            params.copyWithDeps(Suppliers.ofInstance(ImmutableSortedSet.of()),
                    Suppliers.ofInstance(ImmutableSortedSet.of())),
            pathResolver, compileRules.build(), deps.build());
}

From source file:com.facebook.buck.rules.InputRule.java

/**
 * Convert a set of input file paths to InputRules.
 *//*w ww  . j a va2  s .  c om*/
public static ImmutableSortedSet<InputRule> inputPathsAsInputRules(Iterable<String> paths,
        Function<String, String> pathRelativizer) {
    ImmutableSortedSet.Builder<InputRule> builder = ImmutableSortedSet.naturalOrder();
    for (String path : paths) {
        builder.add(new InputRule(new File(pathRelativizer.apply(path)), path));
    }
    return builder.build();
}

From source file:se.sics.caracaldb.utils.TimestampIdFactory.java

@Override
public synchronized ImmutableSortedSet<UUID> newIds(int n) {
    checkUpdateTs();/*from   w ww.j a  v a  2s.  co  m*/
    ImmutableSortedSet.Builder<UUID> idBuilder = ImmutableSortedSet.naturalOrder();
    for (int i = 0; i < n; i++) {
        idBuilder.add(nextId());
    }
    return idBuilder.build();
}

From source file:com.isotrol.impe3.web20.impl.TimeMap.java

private TimeMap(TimeMapConfig config, SchedulerComponent scheduler, WithTimeMapManager<M> manager) {
    this.maps = new MapMaker().makeMap();
    this.manager = checkNotNull(manager);
    ImmutableSortedSet.Builder<Long> ib = ImmutableSortedSet.naturalOrder();
    if (config.isGlobal()) {
        ib.add(Long.MAX_VALUE);//from  w ww  . j a v  a 2s .c o m
        this.maps.put(Long.MAX_VALUE, manager.createEmptyTimeMap());
        scheduler.scheduleWithFixedDelay(new Task(null), 0L, config.getDelay(), TimeUnit.SECONDS);
    }
    for (Long seconds : config.getIntervals()) {
        ib.add(seconds);
        this.maps.put(seconds, manager.createEmptyTimeMap());
        scheduler.scheduleWithFixedDelay(new Task(seconds), 0L, config.getDelay(), TimeUnit.SECONDS);
    }
    this.intervals = ib.build();
}

From source file:com.facebook.buck.apple.Flavors.java

/**
 * Propagate flavors represented by the given {@link FlavorDomain} objects from a parent target to
 * its dependencies./* ww w . java 2 s .c o m*/
 */
public static ImmutableSortedSet<BuildTarget> propagateFlavorDomains(BuildTarget target,
        Iterable<FlavorDomain<?>> domains, Iterable<BuildTarget> deps) {

    Set<Flavor> flavors = new HashSet<>();

    // For each flavor domain, extract the corresponding flavor from the parent target and
    // verify that each dependency hasn't already set this flavor.
    for (FlavorDomain<?> domain : domains) {

        // Now extract all relevant domain flavors from our parent target.
        ImmutableSet<Flavor> flavorSet = Sets.intersection(domain.getFlavors(), target.getFlavors())
                .immutableCopy();

        if (flavorSet.isEmpty()) {
            throw new HumanReadableException("%s: no flavor for \"%s\"", target, domain.getName());
        }
        flavors.addAll(flavorSet);

        // First verify that our deps are not already flavored for our given domains.
        for (BuildTarget dep : deps) {
            if (domain.getFlavor(dep).isPresent()) {
                throw new HumanReadableException("%s: dep %s already has flavor for \"%s\" : %s", target, dep,
                        domain.getName(), flavorSet.toString());
            }
        }
    }

    ImmutableSortedSet.Builder<BuildTarget> flavoredDeps = ImmutableSortedSet.naturalOrder();

    // Now flavor each dependency with the relevant flavors.
    for (BuildTarget dep : deps) {
        flavoredDeps.add(dep.withAppendedFlavors(flavors));
    }

    return flavoredDeps.build();
}

From source file:com.facebook.buck.rules.CommandTool.java

@Override
public ImmutableCollection<SourcePath> getInputs() {
    ImmutableSortedSet.Builder<SourcePath> inputs = ImmutableSortedSet.naturalOrder();
    if (baseTool.isPresent()) {
        inputs.addAll(baseTool.get().getInputs());
    }/*from   w  w  w  . j  av  a2 s  .  c o  m*/
    for (Arg arg : args) {
        inputs.addAll(arg.getInputs());
    }
    inputs.addAll(extraInputs);
    return inputs.build();
}

From source file:com.palantir.atlasdb.table.description.render.ImportRenderer.java

private SortedSet<String> importsSortedBySimpleName() {
    ImmutableSortedSet.Builder<String> sortedImports = ImmutableSortedSet.naturalOrder();
    for (Class<?> clazz : imports) {
        sortedImports.add(clazz.getSimpleName());
    }//w ww  . j  av  a2s  .  c o  m
    return sortedImports.build();
}

From source file:com.facebook.buck.apple.AppleAssetCatalogDescription.java

@Override
public AppleAssetCatalog createBuildable(BuildRuleParams params, Arg args) {
    final ProjectFilesystem projectFilesystem = params.getProjectFilesystem();
    final Set<Path> dirs = args.dirs;
    Supplier<Collection<Path>> inputPathsSupplier = Suppliers.memoize(new Supplier<Collection<Path>>() {
        @Override/*from  ww w .j av a 2s.  c om*/
        public Collection<Path> get() {
            ImmutableSortedSet.Builder<Path> paths = ImmutableSortedSet.naturalOrder();
            for (Path dir : dirs) {
                try {
                    paths.addAll(projectFilesystem.getFilesUnderPath(dir));
                } catch (IOException e) {
                    throw new HumanReadableException(e, "Error traversing directory: %s.", dir);
                }
            }
            return paths.build();
        }
    });
    return new AppleAssetCatalog(inputPathsSupplier, args);
}