Example usage for com.google.common.collect ImmutableSortedSet.Builder add

List of usage examples for com.google.common.collect ImmutableSortedSet.Builder add

Introduction

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

Prototype

boolean add(E e);

Source Link

Document

Adds the specified element to this set if it is not already present (optional operation).

Usage

From source file:com.publictransitanalytics.scoregenerator.workflow.Calculation.java

private static NavigableSet<LocalDateTime> getTaskTimes(final LocalDateTime startTime,
        final LocalDateTime endTime, final Duration samplingInterval) {
    final ImmutableSortedSet.Builder<LocalDateTime> builder = ImmutableSortedSet.naturalOrder();
    if (endTime == null) {
        builder.add(startTime);
    } else {//from   w w w .ja v a  2s. com
        LocalDateTime time = startTime;
        while (time.isBefore(endTime)) {
            builder.add(time);
            time = time.plus(samplingInterval);
        }
    }
    return builder.build();
}

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

private static void addValues(ImmutableSortedSet.Builder<Float> xset, ImmutableSortedSet.Builder<Float> yset,
        ImmutableSortedSet.Builder<Float> zset, Iterable<Position> positions) {
    for (Position position : positions) {
        xset.add(position.northing());
        yset.add(position.easting());/*from   w w w. jav  a2s .  c  o  m*/
        if (position.hasAltitude())
            zset.add(position.altitude());
    }
}

From source file:com.google.devtools.build.lib.bazel.rules.android.AndroidRepositoryUtils.java

/**
 * Gets the numeric api levels from the contents of the platforms directory in descending order.
 *
 * Note that the directory entries are assumed to match {@code android-[0-9]+}. Any directory
 * entries that are not directories or do not match that pattern are ignored.
 *///from w w  w .  java2  s.  co  m
static ImmutableSortedSet<Integer> getApiLevels(Dirents platformsDirectories) {
    ImmutableSortedSet.Builder<Integer> apiLevels = ImmutableSortedSet.reverseOrder();
    for (Dirent platformDirectory : platformsDirectories) {
        if (platformDirectory.getType() != Dirent.Type.DIRECTORY) {
            continue;
        }
        Matcher matcher = PLATFORMS_API_LEVEL_PATTERN.matcher(platformDirectory.getName());
        if (matcher.matches()) {
            apiLevels.add(Integer.parseInt(matcher.group(1)));
        }
    }
    return apiLevels.build();
}

From source file:com.b2international.snowowl.snomed.api.rest.CodeSystemVersionRestRequests.java

public static SortedSet<String> getEffectiveDates(String shortName) {
    Map<?, ?> response = getVersions(shortName).extract().as(Map.class);

    if (!response.containsKey("items")) {
        return ImmutableSortedSet.of();
    } else {/*from w w w  .j  ava  2  s  .  c o m*/
        ImmutableSortedSet.Builder<String> effectiveDatesBuilder = ImmutableSortedSet.naturalOrder();
        @SuppressWarnings("unchecked")
        List<Map<?, ?>> items = (List<Map<?, ?>>) response.get("items");
        for (Map<?, ?> version : items) {
            String effectiveDate = (String) version.get("effectiveDate");
            effectiveDatesBuilder.add(effectiveDate);
        }

        return effectiveDatesBuilder.build();
    }
}

From source file:org.gradle.api.internal.tasks.properties.TaskPropertyUtils.java

public static <T extends TaskFilePropertySpec> SortedSet<T> collectFileProperties(String displayName,
        Iterable<? extends T> fileProperties) {
    Set<String> names = Sets.newHashSet();
    ImmutableSortedSet.Builder<T> builder = ImmutableSortedSet.naturalOrder();
    for (T propertySpec : fileProperties) {
        String propertyName = propertySpec.getPropertyName();
        if (!names.add(propertyName)) {
            throw new IllegalArgumentException(
                    String.format("Multiple %s file properties with name '%s'", displayName, propertyName));
        }//from   w ww. ja v a2  s .  c o m
        builder.add(propertySpec);
    }
    return builder.build();
}

From source file:com.google.devtools.build.lib.bazel.rules.android.AndroidRepositoryFunction.java

/**
 * Gets the numeric api levels from the contents of the platforms directory in descending order.
 *
 * <p>Note that the directory entries are assumed to match {@code android-[0-9]+}. Any directory
 * entries that are not directories or do not match that pattern are ignored.
 *//*  w w  w. j av  a  2  s  .c  o  m*/
static final ImmutableSortedSet<Integer> getApiLevels(Dirents platformsDirectories) {
    ImmutableSortedSet.Builder<Integer> apiLevels = ImmutableSortedSet.reverseOrder();
    for (Dirent platformDirectory : platformsDirectories) {
        if (platformDirectory.getType() != Dirent.Type.DIRECTORY) {
            continue;
        }
        Matcher matcher = PLATFORMS_API_LEVEL_PATTERN.matcher(platformDirectory.getName());
        if (matcher.matches()) {
            apiLevels.add(Integer.parseInt(matcher.group(1)));
        }
    }
    return apiLevels.build();
}

From source file:com.facebook.buck.jvm.java.JavaLibraryRules.java

public static ImmutableSortedSet<SourcePath> getAbiInputs(BuildRuleResolver resolver,
        Iterable<BuildRule> inputs) throws NoSuchBuildTargetException {
    ImmutableSortedSet.Builder<SourcePath> abiRules = ImmutableSortedSet.naturalOrder();
    for (BuildRule dep : inputs) {
        if (dep instanceof HasJavaAbi) {
            Optional<BuildTarget> abiJarTarget = ((HasJavaAbi) dep).getAbiJar();
            if (abiJarTarget.isPresent()) {
                resolver.requireRule(abiJarTarget.get());
                abiRules.add(new BuildTargetSourcePath(abiJarTarget.get()));
            }//  w ww  .j ava 2  s . co m
        }
    }
    return abiRules.build();
}

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

public static View deserialiseView(ByteBuf buf) {
    int id = buf.readInt();
    int memsize = buf.readInt();
    ImmutableSortedSet.Builder<Address> addrs = ImmutableSortedSet.naturalOrder();
    for (int i = 0; i < memsize; i++) {
        Address addr = (Address) SpecialSerializers.AddressSerializer.INSTANCE.fromBinary(buf,
                Optional.absent());
        addrs.add(addr);
    }/*w  w w  .j a  va  2  s  . c o  m*/
    return new View(addrs.build(), id);
}

From source file:com.facebook.buck.rust.RustLinkables.java

static ImmutableSortedSet<Path> getDependencyPaths(BuildRule rule) {
    final ImmutableSortedSet.Builder<Path> builder = ImmutableSortedSet.naturalOrder();

    new AbstractBreadthFirstTraversal<BuildRule>(ImmutableSet.of(rule)) {
        @Override//from  w  w w  .  j  av  a 2s  .c  om
        public ImmutableSet<BuildRule> visit(BuildRule rule) {
            if (rule instanceof RustLinkable) {
                RustLinkable linkable = (RustLinkable) rule;
                builder.add(linkable.getLinkPath().getParent());
                return rule.getDeps();
            } else {
                return ImmutableSet.of();
            }
        }
    }.start();

    return builder.build();
}

From source file:com.google.devtools.build.android.SplitConfigurationFilter.java

/** Generates a SplitConfigurationFilter from the suffix of a split generated by aapt. */
static SplitConfigurationFilter fromFilenameSuffix(String suffix) {
    ImmutableSortedSet.Builder<ResourceConfiguration> configs = ImmutableSortedSet.reverseOrder();
    for (String configuration : Splitter.on('_').split(suffix)) {
        configs.add(ResourceConfiguration.fromString(configuration));
    }// w w w .  j a  va  2s  . c om
    return new SplitConfigurationFilter(suffix, configs.build());
}