Java Code Examples for com.google.common.collect.ImmutableSet#copyOf()

The following examples show how to use com.google.common.collect.ImmutableSet#copyOf() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BatchShapeReader.java    From RDFUnit with Apache License 2.0 6 votes vote down vote up
public Set<Shape> getShapesFromModel(Model model) {
    ConcurrentLinkedQueue<Shape> shapes = new ConcurrentLinkedQueue<>();

    ImmutableSet.Builder<Resource> shapeResourceBuilder = ImmutableSet.builder();

    addShapesAsInstancesOf(model, shapeResourceBuilder);
    addShapesAsObjectsOf(model, shapeResourceBuilder);
    addShapesAsSubjectsOf(model, shapeResourceBuilder);

    ImmutableSet<Resource> shapeResources = shapeResourceBuilder.build();
    shapeResources.forEach(resource -> shapes.add(ShapeReader.create().read(resource)));
    addShapeListsAsObjectsOf(model).forEach(ls -> {
        shapes.add(ls);
        shapes.addAll(ls.getShapes());
    });

    return ImmutableSet.copyOf(shapes);
}
 
Example 2
Source File: ActionGraphDump.java    From bazel with Apache License 2.0 6 votes vote down vote up
public ActionGraphDump(
    List<String> actionGraphTargets,
    boolean includeActionCmdLine,
    boolean includeArtifacts,
    AqueryActionFilter actionFilters,
    boolean includeParamFiles) {
  this.actionGraphTargets = ImmutableSet.copyOf(actionGraphTargets);
  this.includeActionCmdLine = includeActionCmdLine;
  this.includeArtifacts = includeArtifacts;
  this.actionFilters = actionFilters;
  this.includeParamFiles = includeParamFiles;

  knownRuleClassStrings = new KnownRuleClassStrings(actionGraphBuilder);
  knownArtifacts = new KnownArtifacts(actionGraphBuilder);
  knownConfigurations = new KnownConfigurations(actionGraphBuilder);
  knownNestedSets = new KnownNestedSets(actionGraphBuilder, knownArtifacts);
  knownAspectDescriptors = new KnownAspectDescriptors(actionGraphBuilder);
  knownTargets = new KnownTargets(actionGraphBuilder, knownRuleClassStrings);
}
 
Example 3
Source File: ControllerMetadataRecordSerializerTest.java    From pravega with Apache License 2.0 6 votes vote down vote up
@Test
public void streamTruncationRecordTest() {
    Map<StreamSegmentRecord, Integer> span = new HashMap<>();
    span.put(StreamSegmentRecord.newSegmentRecord(0, 0, 0L, 0.0, 1.0), 0);
    Map<Long, Long> streamCut = new HashMap<>();
    streamCut.put(0L, 0L);
    Set<Long> set = new HashSet<>();
    set.add(0L);
    StreamTruncationRecord record = new StreamTruncationRecord(ImmutableMap.copyOf(streamCut),
            ImmutableMap.copyOf(span), ImmutableSet.copyOf(set), ImmutableSet.copyOf(set), 0L, true);
    assertEquals(StreamTruncationRecord.fromBytes(record.toBytes()), record);
    assertTrue(record.isUpdating());
    StreamTruncationRecord completed = StreamTruncationRecord.complete(record);
    assertEquals(StreamTruncationRecord.fromBytes(completed.toBytes()), completed);
    assertTrue(!completed.isUpdating());
}
 
Example 4
Source File: FetchData.java    From james-project with Apache License 2.0 5 votes vote down vote up
private FetchData(EnumSet<Item> itemToFetch, Set<BodyFetchElement> bodyElements, boolean setSeen, long changedSince, boolean vanished) {
    this.itemToFetch = EnumSet.copyOf(itemToFetch);
    this.bodyElements = ImmutableSet.copyOf(bodyElements);
    this.setSeen = setSeen;
    this.changedSince = changedSince;
    this.vanished = vanished;
}
 
Example 5
Source File: FileAuthStorage.java    From sailfish-core with Apache License 2.0 5 votes vote down vote up
@Override
public Set<User> getUsers() {
    try {
        usersLock.readLock().lock();
        return ImmutableSet.copyOf(users);
    } finally {
        usersLock.readLock().unlock();
    }
}
 
Example 6
Source File: Criterion.java    From genie with Apache License 2.0 5 votes vote down vote up
/**
 * Copy the contents of the given {@link Criterion} but use the supplied status.
 *
 * @param criterion The {@link Criterion} to copy
 * @param status    The status to use
 */
public Criterion(final Criterion criterion, final String status) {
    this.id = criterion.id;
    this.name = criterion.name;
    this.version = criterion.version;
    this.status = status;
    this.tags = ImmutableSet.copyOf(criterion.getTags());
}
 
Example 7
Source File: DistributedRouteStore.java    From onos with Apache License 2.0 5 votes vote down vote up
@Override
public Collection<RouteSet> getRoutes(RouteTableId table) {
    RouteTable routeTable = routeTables.get(table);
    if (routeTable == null) {
        return Collections.emptySet();
    } else {
        return ImmutableSet.copyOf(routeTable.getRoutes());
    }
}
 
Example 8
Source File: InterfacesInterface.java    From batfish with Apache License 2.0 4 votes vote down vote up
public void setBridgePorts(Set<String> bridgePorts) {
  _bridgePorts = ImmutableSet.copyOf(bridgePorts);
}
 
Example 9
Source File: StaticCatalogStore.java    From presto with Apache License 2.0 4 votes vote down vote up
public StaticCatalogStore(ConnectorManager connectorManager, File catalogConfigurationDir, List<String> disabledCatalogs)
{
    this.connectorManager = connectorManager;
    this.catalogConfigurationDir = catalogConfigurationDir;
    this.disabledCatalogs = ImmutableSet.copyOf(disabledCatalogs);
}
 
Example 10
Source File: Interface.java    From batfish with Apache License 2.0 4 votes vote down vote up
public Builder setDependencies(@Nonnull Iterable<Dependency> dependencies) {
  _dependencies = ImmutableSet.copyOf(dependencies);
  return this;
}
 
Example 11
Source File: ResolvedReachabilityParameters.java    From batfish with Apache License 2.0 4 votes vote down vote up
public Builder setFinalNodes(Set<String> finalNodes) {
  _finalNodes = ImmutableSet.copyOf(finalNodes);
  return this;
}
 
Example 12
Source File: WorldRetrogen.java    From simpleretrogen with GNU General Public License v3.0 4 votes vote down vote up
@EventHandler
public void serverAboutToStart(FMLServerAboutToStartEvent evt)
{
    this.pendingWork = new MapMaker().weakKeys().makeMap();
    this.completedWork = new MapMaker().weakKeys().makeMap();
    this.completedWorkLocks = new MapMaker().weakKeys().makeMap();

    Set<IWorldGenerator> worldGens = ObfuscationReflectionHelper.getPrivateValue(GameRegistry.class, null, "worldGenerators");
    Map<IWorldGenerator,Integer> worldGenIdx = ObfuscationReflectionHelper.getPrivateValue(GameRegistry.class, null, "worldGeneratorIndex");

    for (String retro : ImmutableSet.copyOf(retros.keySet()))
    {
        if (!delegates.containsKey(retro))
        {
            FMLLog.info("Substituting worldgenerator %s with delegate", retro);
            for (Iterator<IWorldGenerator> iterator = worldGens.iterator(); iterator.hasNext();)
            {
                IWorldGenerator wg = iterator.next();
                if (wg.getClass().getName().equals(retro))
                {
                    iterator.remove();
                    TargetWorldWrapper tww = new TargetWorldWrapper();
                    tww.delegate = wg;
                    tww.tag = retro;
                    worldGens.add(tww);
                    Integer idx = worldGenIdx.remove(wg);
                    worldGenIdx.put(tww, idx);
                    FMLLog.info("Successfully substituted %s with delegate", retro);
                    delegates.put(retro, tww);
                    break;
                }
            }

            if (!delegates.containsKey(retro))
            {
                FMLLog.warning("WorldRetrogen was not able to locate world generator class %s, it will be skipped, found %s", retro, worldGens);
                retros.remove(retro);
            }
        }
    }
}
 
Example 13
Source File: MoreApt.java    From j2cl with Apache License 2.0 4 votes vote down vote up
/** Returns the list of the type and its super types without a specific order. */
public static ImmutableSet<TypeElement> getTypeHierarchy(TypeElement typeElement) {
  return ImmutableSet.copyOf(getHierarchyImpl(typeElement, true));
}
 
Example 14
Source File: ResolvedReachabilityParameters.java    From batfish with Apache License 2.0 4 votes vote down vote up
public Builder setRequiredTransitNodes(Set<String> nodes) {
  _requiredTransitNodes = ImmutableSet.copyOf(nodes);
  return this;
}
 
Example 15
Source File: KeySetIndexProxyGroupIntegrationTest.java    From exonum-java-binding with Apache License 2.0 4 votes vote down vote up
private static <E> Set<E> getAllValuesFrom(KeySetIndexProxy<E> set) {
  return ImmutableSet.copyOf(set.iterator());
}
 
Example 16
Source File: CompletionMetadata.java    From batfish with Apache License 2.0 4 votes vote down vote up
public @Nonnull Builder setStructureNames(Set<String> structureNames) {
  _structureNames = ImmutableSet.copyOf(structureNames);
  return this;
}
 
Example 17
Source File: NewNativeTargetProjectMutator.java    From buck with Apache License 2.0 4 votes vote down vote up
public NewNativeTargetProjectMutator setSourcesWithFlags(Set<SourceWithFlags> sourcesWithFlags) {
  this.sourcesWithFlags = ImmutableSet.copyOf(sourcesWithFlags);
  return this;
}
 
Example 18
Source File: DistributedVirtualNetworkStore.java    From onos with Apache License 2.0 4 votes vote down vote up
@Override
public Set<TenantId> getTenantIds() {
    return ImmutableSet.copyOf(tenantIdSet);
}
 
Example 19
Source File: AnalysisPhaseStartedEvent.java    From bazel with Apache License 2.0 2 votes vote down vote up
/**
 * Construct the event.
 * @param targets The set of active targets that remain.
 */
public AnalysisPhaseStartedEvent(Collection<Target> targets) {
  this.targets = ImmutableSet.copyOf(targets);
}
 
Example 20
Source File: YangInstanceIdentifier.java    From yangtools with Eclipse Public License 1.0 2 votes vote down vote up
/**
 * Construct new augmentation identifier using supplied set of possible
 * child nodes.
 *
 * @param childNames
 *            Set of possible child nodes.
 */
public AugmentationIdentifier(final Set<QName> childNames) {
    this.childNames = ImmutableSet.copyOf(childNames);
}