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

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

Introduction

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

Prototype

public static <E extends Comparable<? super E>> ImmutableSortedSet<E> copyOf(E[] elements) 

Source Link

Usage

From source file:com.facebook.buck.android.NdkLibrary.java

protected NdkLibrary(BuildTarget buildTarget, Set<SourcePath> sources, List<String> flags, boolean isAsset,
        Optional<String> ndkVersion) {
    this.isAsset = isAsset;

    this.makefileDirectory = buildTarget.getBasePathWithSlash();
    this.lastPathComponent = "__lib" + buildTarget.getShortName();
    this.buildArtifactsDirectory = getBuildArtifactsDirectory(buildTarget, true /* isScratchDir */);
    this.genDirectory = getBuildArtifactsDirectory(buildTarget, false /* isScratchDir */);

    Preconditions.checkArgument(!sources.isEmpty(),
            "Must include at least one file (Android.mk?) in ndk_library rule");
    this.sources = ImmutableSortedSet.copyOf(sources);
    this.flags = ImmutableList.copyOf(flags);

    this.ndkVersion = Preconditions.checkNotNull(ndkVersion);
}

From source file:com.github.gv2011.util.icol.guava.ISortedSetWrapper.java

@Override
public ISortedSet<E> headSet(final E toElement) {
    return new ISortedSetWrapper<>(ImmutableSortedSet.copyOf(delegate.headSet(toElement)));
}

From source file:com.opengamma.web.config.ConfigTypesProvider.java

/**
 * Gets the set of config keys./*ww w  .  j a  va 2 s .c o  m*/
 * 
 * @return the types, not null
 */
public ImmutableSortedSet<String> getConfigTypes() {
    return ImmutableSortedSet.copyOf(_configTypeMap.keySet());
}

From source file:se.sics.caracaldb.View.java

public View copy() {
    return new View(ImmutableSortedSet.copyOf(members), id);
}

From source file:io.wcm.config.core.management.impl.ParameterPersistenceImpl.java

private ParameterPersistenceData toData(Map<String, Object> valuesFromProvider) {
    String[] lockedParameterNamesArray = (String[]) valuesFromProvider.get(PN_LOCKED_PARAMETER_NAMES);
    if (lockedParameterNamesArray != null) {
        Map<String, Object> values = new HashMap<>(valuesFromProvider);
        values.remove(PN_LOCKED_PARAMETER_NAMES);
        return new ParameterPersistenceData(values, ImmutableSortedSet.copyOf(lockedParameterNamesArray));
    } else {//from w w  w .  j a v a 2  s.  c o  m
        return new ParameterPersistenceData(valuesFromProvider, ImmutableSortedSet.<String>of());
    }
}

From source file:com.facebook.buck.distributed.DistributedCellProviderFactory.java

public static CellProvider create(DistBuildCellParams rootCell,
        ImmutableMap<Path, DistBuildCellParams> cellParams, CellPathResolver rootCellPathResolver,
        UnconfiguredBuildTargetFactory unconfiguredBuildTargetFactory) {
    Map<String, Path> cellPaths = cellParams.values().stream().filter(p -> p.getCanonicalName().isPresent())
            .collect(Collectors.toMap(p -> p.getCanonicalName().get(), p -> p.getFilesystem().getRootPath()));
    ImmutableSet<String> declaredCellNames = ImmutableSet.copyOf(cellPaths.keySet());
    Path rootCellPath = rootCell.getFilesystem().getRootPath();
    DefaultCellPathResolver rootCellResolver = DefaultCellPathResolver.of(rootCellPath, cellPaths);

    return new CellProvider(cellProvider -> CacheLoader.from(cellPath -> {
        DistBuildCellParams cellParam = Objects.requireNonNull(cellParams.get(cellPath),
                "This should only be called for secondary cells.");
        Path currentCellRoot = cellParam.getFilesystem().getRootPath();
        Preconditions.checkState(!currentCellRoot.equals(rootCellPath));
        CellPathResolver currentCellResolver = rootCellResolver;
        // The CellPathResolverView is required because it makes the
        // [RootPath<->CanonicalName] resolver methods non-symmetrical to handle the
        // fact/*www  . ja  v  a2  s.  c  o m*/
        // that relative main cell from inside a secondary cell resolves actually to
        // secondary cell. If the DefaultCellPathResolver is used, then it would return
        // a BuildTarget as if it belonged to the main cell.
        currentCellResolver = new CellPathResolverView(rootCellResolver, declaredCellNames, currentCellRoot);
        CellPathResolver cellPathResolverForParser = currentCellResolver;
        BuckConfig configWithResolver = cellParam.getConfig()
                .withBuildTargetParser(buildTargetName -> unconfiguredBuildTargetFactory
                        .create(cellPathResolverForParser, buildTargetName));
        RuleKeyConfiguration ruleKeyConfiguration = ConfigRuleKeyConfigurationFactory.create(configWithResolver,
                cellParam.getBuckModuleManager());
        ToolchainProvider toolchainProvider = new DefaultToolchainProvider(cellParam.getPluginManager(),
                cellParam.getEnvironment(), configWithResolver, cellParam.getFilesystem(),
                cellParam.getProcessExecutor(), cellParam.getExecutableFinder(), ruleKeyConfiguration);

        return ImmutableCell.of(ImmutableSortedSet.copyOf(cellParams.keySet()),
                // Distributed builds don't care about cell names, use a sentinel value that
                // will show up if it actually does care about them.
                cellParam.getCanonicalName(), cellParam.getFilesystem(), configWithResolver, cellProvider,
                toolchainProvider, ruleKeyConfiguration, currentCellResolver);
    }), cellProvider -> RootCellFactory.create(cellProvider, rootCellResolver, rootCellPathResolver,
            rootCell.getFilesystem(), rootCell.getBuckModuleManager(), rootCell.getPluginManager(),
            rootCell.getConfig(), rootCell.getEnvironment(), rootCell.getProcessExecutor(),
            rootCell.getExecutableFinder()));
}

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

public DescribedRuleBuilder(Description<T> description, final BuildRuleFactoryParams params)
        throws NoSuchBuildTargetException {
    this.description = Preconditions.checkNotNull(description);
    this.ruleFactoryParams = Preconditions.checkNotNull(params);
    this.target = params.target;

    /*/*from w  w w. jav a2 s .c  o  m*/
     * We're about to gather everything that looks like a dependency so that we can add them to the
     * BuildRule. We'll keep the actual dependencies declared in the "deps" parameter separate since
     * they'll be needed when constructing the Buildable.
     */

    final ImmutableSortedSet.Builder<BuildTarget> extraDeps = ImmutableSortedSet.naturalOrder();
    final ImmutableSortedSet.Builder<BuildTarget> declaredDeps = ImmutableSortedSet.naturalOrder();
    for (String rawDep : params.getOptionalListAttribute("deps")) {
        BuildTarget target = params.resolveBuildTarget(rawDep);
        declaredDeps.add(target);
        extraDeps.add(target);
    }
    this.declaredDeps = declaredDeps.build();

    // Scan the input to find possible BuildTargets, necessary for loading dependent rules.
    TypeCoercerFactory typeCoercerFactory = new TypeCoercerFactory();
    T arg = description.createUnpopulatedConstructorArg();
    for (Field field : arg.getClass().getFields()) {
        ParamInfo info = new ParamInfo(typeCoercerFactory, Paths.get(target.getBasePath()), field);
        if (info.hasElementTypes(BuildRule.class, SourcePath.class)) {
            detectBuildTargetsForParameter(extraDeps, info, params);
        }
    }
    this.extraDeps = ImmutableSortedSet.copyOf(Sets.difference(extraDeps.build(), this.declaredDeps));

    ImmutableSet.Builder<BuildTargetPattern> allVisibilities = ImmutableSet.builder();
    for (String rawVis : params.getOptionalListAttribute("visibility")) {
        allVisibilities
                .add(params.buildTargetPatternParser.parse(rawVis, ParseContext.forVisibilityArgument()));
    }
    this.visibilities = allVisibilities.build();
}

From source file:com.opengamma.basics.currency.MultiCurrencyAmount.java

/**
 * Obtains a {@code MultiCurrencyAmount} from a list of {@code CurrencyAmount} objects.
 * <p>/*  w  ww  . ja v a 2 s  .c  om*/
 * It is an error for the input to contain the same currency twice.
 * 
 * @param amounts  the amounts
 * @return the amount
 */
public static MultiCurrencyAmount of(Iterable<CurrencyAmount> amounts) {
    ArgChecker.noNulls(amounts, "amounts");
    Map<Currency, CurrencyAmount> map = new HashMap<Currency, CurrencyAmount>();
    for (CurrencyAmount amount : amounts) {
        if (map.put(amount.getCurrency(), amount) != null) {
            throw new IllegalArgumentException("Currency is duplicated: " + amount.getCurrency());
        }
    }
    return new MultiCurrencyAmount(ImmutableSortedSet.copyOf(map.values()));
}

From source file:com.google.devtools.moe.client.project.ProjectConfig.java

/**
 * Returns the {@link RepositoryConfig} in this config with the given name.
 *
 * @throws MoeProblem if no such repository with the given name exists
 *///from  w  w w  . j  a  va 2s.  c  o m
public RepositoryConfig getRepositoryConfig(String repositoryName) {
    if (!repositories().containsKey(repositoryName)) {
        throw new MoeProblem("No such repository '" + repositoryName + "' in the config. Found: "
                + ImmutableSortedSet.copyOf(repositories().keySet()));
    }
    return repositories().get(repositoryName);
}

From source file:org.jclouds.ibm.smartcloud.domain.Image.java

public Image(String name, URI manifest, State state, Visibility visibility, String owner, String platform,
        Architecture architecture, Date createdTime, String location, Set<InstanceType> supportedInstanceTypes,
        Set<String> productCodes, URI documentation, String id, String description) {
    this.name = name;
    this.manifest = manifest;
    this.state = state;
    this.visibility = visibility;
    this.owner = owner;
    this.platform = platform;
    this.architecture = architecture;
    this.createdTime = createdTime;
    this.location = location;
    this.supportedInstanceTypes = ImmutableSortedSet.copyOf(supportedInstanceTypes);
    this.productCodes = ImmutableSortedSet.copyOf(productCodes);
    this.documentation = documentation;
    this.id = id;
    this.description = description;
}