下面列出了com.google.common.collect.ImmutableSet#copyOf ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
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);
}
@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());
}
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);
}
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;
}
@Override
public Set<User> getUsers() {
try {
usersLock.readLock().lock();
return ImmutableSet.copyOf(users);
} finally {
usersLock.readLock().unlock();
}
}
@Override
public Collection<RouteSet> getRoutes(RouteTableId table) {
RouteTable routeTable = routeTables.get(table);
if (routeTable == null) {
return Collections.emptySet();
} else {
return ImmutableSet.copyOf(routeTable.getRoutes());
}
}
/**
* 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());
}
private static <E> Set<E> getAllValuesFrom(KeySetIndexProxy<E> set) {
return ImmutableSet.copyOf(set.iterator());
}
@Override
public Set<TenantId> getTenantIds() {
return ImmutableSet.copyOf(tenantIdSet);
}
public NewNativeTargetProjectMutator setSourcesWithFlags(Set<SourceWithFlags> sourcesWithFlags) {
this.sourcesWithFlags = ImmutableSet.copyOf(sourcesWithFlags);
return this;
}
public @Nonnull Builder setStructureNames(Set<String> structureNames) {
_structureNames = ImmutableSet.copyOf(structureNames);
return this;
}
public void setBridgePorts(Set<String> bridgePorts) {
_bridgePorts = ImmutableSet.copyOf(bridgePorts);
}
public Builder setRequiredTransitNodes(Set<String> nodes) {
_requiredTransitNodes = ImmutableSet.copyOf(nodes);
return this;
}
/** 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));
}
@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);
}
}
}
}
public Builder setFinalNodes(Set<String> finalNodes) {
_finalNodes = ImmutableSet.copyOf(finalNodes);
return this;
}
public Builder setDependencies(@Nonnull Iterable<Dependency> dependencies) {
_dependencies = ImmutableSet.copyOf(dependencies);
return this;
}
public StaticCatalogStore(ConnectorManager connectorManager, File catalogConfigurationDir, List<String> disabledCatalogs)
{
this.connectorManager = connectorManager;
this.catalogConfigurationDir = catalogConfigurationDir;
this.disabledCatalogs = ImmutableSet.copyOf(disabledCatalogs);
}
/**
* Construct the event.
* @param targets The set of active targets that remain.
*/
public AnalysisPhaseStartedEvent(Collection<Target> targets) {
this.targets = ImmutableSet.copyOf(targets);
}
/**
* 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);
}