public Collection<ManagedBundle> getInstalledWrapperBundles() { synchronized (managedBundlesRecord) { return MutableSet.copyOf(managedBundlesRecord.wrapperBundles.values()); } }
@Override public Set<RelationshipType<? super T,? extends BrooklynObject>> getRelationshipTypes() { synchronized (relations) { return MutableSet.copyOf(relationshipTypes.values()); } }
/** as {@link MutableList#asUnmodifiableCopy()} */ public Set<V> asUnmodifiableCopy() { return Collections.unmodifiableSet(MutableSet.copyOf(this)); }
@Override public Set<ConfigKey<?>> findKeysDeclared(Predicate<? super ConfigKey<?>> filter) { return MutableSet.copyOf(Iterables.filter(config.getAllConfigAsConfigKeyMap().keySet(), filter)); }
@SuppressWarnings("unchecked") @Override public <U extends BrooklynObject> Set<U> getRelations(RelationshipType<? super T, U> relationship) { synchronized (relations) { return (Set<U>)MutableSet.copyOf(relations.get(relationship.getRelationshipTypeName())); } }
@Override public Set<Object> apply(Collection<?> input) { // accept null values, so don't use ImmutableSet return (input == null) ? ImmutableSet.<Object>of() : MutableSet.<Object>copyOf(input); }}) .build());
@Override public Set<Object> apply(Collection<?> input) { // accept null values, so don't use ImmutableSet return (input == null) ? ImmutableSet.<Object>of() : MutableSet.<Object>copyOf(input); }}) .build());
private void assertLocationIdsEqual(Iterable<? extends Location> actual, Iterable<? extends Location> expected) { Function<Location, String> locationIdFunction = new Function<Location, String>() { @Override public String apply(@Nullable Location input) { return (input != null) ? input.getId() : null; } }; Set<String> actualIds = MutableSet.copyOf(Iterables.transform(actual, locationIdFunction)); Set<String> expectedIds = MutableSet.copyOf(Iterables.transform(expected, locationIdFunction)); assertEquals(actualIds, expectedIds); } }
@Override public Set<String> apply(final String input) { return MutableSet.copyOf(JavaStringEscapes.unwrapJsonishListIfPossible(input)).asUnmodifiable(); } });
private void setUnusedKeysAsAnonymousKeys(EntitySpec spec, Set<String> keyNamesUsed, ConfigBag bag){ // they aren't flags or known config keys, so must be passed as config keys in order for // EntitySpec to know what to do with them (as they are passed to the spec as flags) for (String key : MutableSet.copyOf(bag.getUnusedConfig().keySet())) { // we don't let a flag with the same name as a config key override the config key // (that's why we check whether it is used) if (!keyNamesUsed.contains(key)) { //Object transformed = new BrooklynComponentTemplateResolver.SpecialFlagsTransformer(loader).apply(bag.getStringKey(key)); spec.configure(ConfigKeys.newConfigKey(Object.class, key.toString()), bag.getStringKey(key)); } } }
@Override public void run() { List<ThreadInfo> currentThreads = getThreadsCalling(StreamGobbler.class); Set<Long> currentThreadIds = MutableSet.copyOf(getThreadId(currentThreads)); currentThreadIds.removeAll(existingThreadIds); assertEquals(currentThreadIds, ImmutableSet.<Long>of()); } });
@Override public List<TaskSummary> children(String taskId, Boolean includeBackground) { Task<?> t = findTask(taskId); Set<TaskSummary> result = MutableSet.copyOf(getSubTaskChildren(t)); if (Boolean.TRUE.equals(includeBackground)) { result.addAll(getBackgroundedChildren(t)); } return MutableList.copyOf(result); }
@Override public Set<ConfigKey<?>> findKeysDeclared(Predicate<? super ConfigKey<?>> filter) { return MutableSet.copyOf(Iterables.filter(bag.getAllConfigAsConfigKeyMap().keySet(), filter)); }
private Iterable<?> mergeIterablesImpl(Iterable<?> val1, Iterable<?> val2, int depthRemaining, Visited visited) { if (depthRemaining < 1) { return val1; } if (val1 instanceof Set) { return mergeSetsImpl((Set<?>)val1, MutableSet.copyOf(val2), depthRemaining, visited); } else { return mergeListsImpl(MutableList.copyOf(val1), val2, depthRemaining, visited); } }
private static Set<Object> makeTags(EntitySpec<?> spec, CatalogItem<?, ?> item) { return makeTags(spec, MutableSet.copyOf(item.tags().getTags())); } private static Set<Object> makeTags(EntitySpec<?> spec, Set<Object> tags) {
public static RegisteredTypeLoadingContext alreadyEncountered(Set<String> encounteredTypeSymbolicNames, String anotherEncounteredType) { BasicRegisteredTypeLoadingContext result = new BasicRegisteredTypeLoadingContext(); MutableSet<String> encounteredTypes = MutableSet.copyOf(encounteredTypeSymbolicNames); encounteredTypes.addIfNotNull(anotherEncounteredType); result.encounteredTypes = encounteredTypes.asUnmodifiable(); return result; }
@Override public void connect(DockerContainer container, VirtualNetwork network) { synchronized (network) { MutableSet<Entity> connected = MutableSet.copyOf(network.sensors().get(VirtualNetwork.CONNECTED_CONTAINERS)); connected.add(container); network.sensors().set(VirtualNetwork.CONNECTED_CONTAINERS, connected.asImmutableCopy()); } network.relations().add(VirtualNetwork.ATTACHED, container); container.relations().add(VirtualNetwork.CONNECTED, network); }
@Override public void disconnect(DockerContainer container, VirtualNetwork network) { synchronized (network) { MutableSet<Entity> connected = MutableSet.copyOf(network.sensors().get(VirtualNetwork.CONNECTED_CONTAINERS)); connected.remove(container); network.sensors().set(VirtualNetwork.CONNECTED_CONTAINERS, connected.asImmutableCopy()); } network.relations().remove(VirtualNetwork.CONNECTED, container); container.relations().remove(VirtualNetwork.CONNECTED, network); }