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

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

Introduction

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

Prototype

public static <E> ImmutableSet<E> copyOf(Iterator<? extends E> elements) 

Source Link

Usage

From source file:io.druid.indexing.common.actions.SegmentNukeAction.java

@JsonCreator
public SegmentNukeAction(@JsonProperty("segments") Set<DataSegment> segments) {
    this.segments = ImmutableSet.copyOf(segments);
}

From source file:org.onosproject.vpls.config.VplsConfig.java

/**
 * Creates a new VPLS configuration.//w ww  . j  a  va  2  s . co m
 *
 * @param name the VPLS name
 * @param ifaces the interfaces associated with the VPLS
 * @param encap the encapsulation type if set
 */
public VplsConfig(String name, Set<String> ifaces, EncapsulationType encap) {
    this.name = checkNotNull(name);
    this.ifaces = checkNotNull(ImmutableSet.copyOf(ifaces));
    this.encap = checkNotNull(encap);
}

From source file:com.google.devtools.build.lib.rules.objc.Xcdatamodels.java

static Iterable<Xcdatamodel> xcdatamodels(IntermediateArtifacts intermediateArtifacts,
        Iterable<Artifact> xcdatamodels) {
    ImmutableSet.Builder<Xcdatamodel> result = new ImmutableSet.Builder<>();
    Multimap<PathFragment, Artifact> artifactsByContainer = byContainer(xcdatamodels);

    for (Map.Entry<PathFragment, Collection<Artifact>> modelDirEntry : artifactsByContainer.asMap()
            .entrySet()) {//from w  ww.  j  a  v a  2  s .co  m
        PathFragment container = modelDirEntry.getKey();
        Artifact outputZip = intermediateArtifacts.compiledMomZipArtifact(container);
        result.add(new Xcdatamodel(outputZip, ImmutableSet.copyOf(modelDirEntry.getValue()), container));
    }

    return result.build();
}

From source file:ratpack.file.FileIo.java

/**
 * Creates a promise for an (open) async file channel.
 * <p>// w w  w .j  ava2  s  .  c o m
 * Uses {@link AsynchronousFileChannel#open(Path, Set, ExecutorService, FileAttribute[])},
 * but uses the current execution's event loop as the executor service and no file attributes.
 *
 * @param file The path of the file to open or create
 * @param options Options specifying how the file is opened
 * @see AsynchronousFileChannel#open(Path, Set, ExecutorService, FileAttribute[])
 * @see #open(Path, Set, FileAttribute[])
 * @return a promise for an open async file channel
 */
public static Promise<AsynchronousFileChannel> open(Path file, OpenOption... options) {
    return open(file, ImmutableSet.copyOf(options));
}

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//from   w ww  .j  a va2s  .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.presto.split.DataStreamManager.java

public DataStreamManager(ConnectorDataStreamProvider... dataStreamProviders) {
    this(ImmutableSet.copyOf(dataStreamProviders));
}

From source file:org.fao.geonet.api.reports.ReportUtils.java

/**
 * Obtains a list of valid groups to apply in filter query
 * taken from requested groups./* w  w  w  .j  a  v a  2s.  c om*/
 *
 * @param context Service context.
 * @param groups Requested list of groups to filter.
 * @return List of valid groups to apply in filter query.
 * @throws Exception Exception retrieving the list of groups for the filter.
 */
public static Set<Integer> groupsForFilter(final ServiceContext context, final List<Integer> groups)
        throws Exception {

    Set<Integer> requestedGroups;

    if (groups == null) {
        requestedGroups = new HashSet<>();
    } else {
        requestedGroups = ImmutableSet.copyOf(groups);
    }

    Profile userProfile = context.getUserSession().getProfile();

    if (userProfile != null && userProfile.equals(Profile.Administrator)) {
        return requestedGroups;
    } else {
        GeonetContext gc = (GeonetContext) context.getHandlerContext(Geonet.CONTEXT_NAME);
        AccessManager am = gc.getBean(AccessManager.class);
        Set<Integer> userGroups = am.getUserGroups(context.getUserSession(), context.getIpAddress(), false);

        // Remove special groups
        userGroups.remove(ReservedGroup.guest.getId());
        userGroups.remove(ReservedGroup.all.getId());
        userGroups.remove(ReservedGroup.intranet.getId());

        // If no specific group requested, filter by user groups
        if (requestedGroups.isEmpty()) {
            return userGroups;

        } else {
            // Remove not allowed groups from request
            Set<Integer> filterRequestedGroups = new HashSet<>();

            for (Integer gr : requestedGroups) {
                if (userGroups.contains(gr)) {
                    filterRequestedGroups.add(gr);
                }
            }

            if (!filterRequestedGroups.isEmpty()) {
                return filterRequestedGroups;
            } else {
                // If no specific group requested, filter by user groups
                return userGroups;
            }
        }
    }
}

From source file:io.github.cloudiator.deployment.domain.JobNewImpl.java

JobNewImpl(String name, Set<Task> tasks, Set<Communication> communications) {

    checkNotNull(name, "name is null");
    checkArgument(!name.isEmpty(), "name is empty");
    checkNotNull(tasks, "tasks is null");
    checkNotNull(communications, "communications is null");

    this.name = name;
    this.tasks = ImmutableSet.copyOf(tasks);
    this.communications = ImmutableSet.copyOf(communications);
}

From source file:com.facebook.buck.core.build.buildable.context.FakeBuildableContext.java

public ImmutableSet<Path> getRecordedArtifacts() {
    return ImmutableSet.copyOf(artifacts);
}

From source file:com.blackducksoftware.bdio.AnonymousNode.java

private AnonymousNode(Type... types) {
    id = "_:N" + UUID.randomUUID().toString().replace("-", "");
    this.types = ImmutableSet.copyOf(types);
    data = new LinkedHashMap<>();
}