本文整理了Java中org.apache.brooklyn.util.collections.MutableSet.of()
方法的一些代码示例,展示了MutableSet.of()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MutableSet.of()
方法的具体详情如下:
包路径:org.apache.brooklyn.util.collections.MutableSet
类名称:MutableSet
方法名:of
暂无
代码示例来源:origin: org.apache.brooklyn/brooklyn-core
@Override
public Collection<BrooklynObject> get() {
return MutableSet.of();
}
});
代码示例来源:origin: org.apache.brooklyn/brooklyn-rest-resources
private static boolean firstEncounter(Throwable t) {
Set<Object> record = MutableSet.of();
while (true) {
record.add(t.getClass());
if (t.getStackTrace().length>0) {
if (record.add(t.getStackTrace()[0])) break;
}
t = t.getCause();
if (t==null) break;
}
return encounteredExceptionRecords.add(record);
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-core
private static Set<ConfigKey<?>> filterOutRuntimeNotReinherited(Set<ConfigKey<?>> inherited) {
Set<ConfigKey<?>> result = MutableSet.of();
for (ConfigKey<?> k: inherited) {
if (ConfigInheritances.isKeyReinheritable(k, InheritanceContext.RUNTIME_MANAGEMENT)) {
result.add(k);
}
}
return result;
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-software-base
/** @return the ports required for a specific child entity */
protected Collection<Integer> getRequiredOpenPorts(Entity entity) {
Set<Integer> ports = MutableSet.of();
addRequiredOpenPortsRecursively(entity, ports);
return ports;
}
代码示例来源:origin: io.brooklyn.clocker/brooklyn-clocker-docker
/** Returns the set of configured ports an entity is listening on. */
public static Set<Integer> getOpenPorts(Entity entity) {
Set<Integer> ports = MutableSet.of(22); // Default for SSH, may be removed
ports.addAll(getMappedPorts(entity).keySet());
return ImmutableSet.copyOf(ports);
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-utils-common
public void testEqualsExact() {
Set<Object> a = MutableSet.<Object>of("a", 1, "b", false);
Set<Object> b = MutableSet.<Object>of("a", 1, "b", false);
Assert.assertEquals(a, b);
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-core
public static Set<Location> getAllInheritedLocations(Entity entity) {
Set<Location> result = MutableSet.of();
while (entity!=null) {
result.addAll(entity.getLocations());
entity = entity.getParent();
}
return result;
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-utils-common
public static <V> MutableSet<V> copyOf(@Nullable Iterator<? extends V> elements) {
if (elements == null || !elements.hasNext()) {
return of();
}
return new MutableSet.Builder<V>().addAll(elements).build();
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-utils-common
public void testEqualsDifferentTypes2() {
Set<Object> a = MutableSet.<Object>of("http");
Set<?> b = ImmutableSet.of("http");
Assert.assertEquals(a, b);
Assert.assertEquals(b, a);
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-core
@Test
public void testMutableSet() throws Exception {
Set<?> obj = MutableSet.of("123");
assertSerializeAndDeserialize(obj);
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-utils-common
@Test
public void testIterableToArrayCoercion() {
String[] s = coerce(ImmutableList.of("a", "b"), String[].class);
Assert.assertTrue(Arrays.equals(s, new String[] {"a", "b"}), "result="+Arrays.toString(s));
Integer[] i = coerce(ImmutableList.of(1, 2), Integer[].class);
Assert.assertTrue(Arrays.equals(i, new Integer[] {1, 2}), "result="+Arrays.toString(i));
int[] i2 = coerce(ImmutableList.of(1, 2), int[].class);
Assert.assertTrue(Arrays.equals(i2, new int[] {1, 2}), "result="+Arrays.toString(i2));
int[] i3 = coerce(MutableSet.of("1", 2), int[].class);
Assert.assertTrue(Arrays.equals(i3, new int[] {1, 2}), "result="+Arrays.toString(i3));
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-utils-common
@Test
public void test12CollapsePropagatedExecutionCompoundBoring() throws Exception {
RuntimeException e = new PropagatedRuntimeException("test1",
new ExecutionException(Exceptions.create(MutableSet.of(new IllegalStateException("test2"), new IllegalStateException("test3")))));
assert12StandardChecks(e, true);
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-software-base
@Test
public void testCanStartSameNode() throws Exception {
// not very interesting as do not have REST when run in this project
// but test BrooklynNodeRestTest in downstream project does
BrooklynNode bn = app.createAndManageChild(EntitySpec.create(BrooklynNode.class, SameBrooklynNodeImpl.class));
bn.start(MutableSet.<Location>of());
Assert.assertEquals(bn.getAttribute(Attributes.SERVICE_UP), (Boolean) true);
// no URI
Assert.assertNull(bn.getAttribute(BrooklynNode.WEB_CONSOLE_URI));
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-software-base
@Test
public void testPassesJavaOptsOverridingDefaults() {
VanillaJavaApp javaProcess = app.createAndManageChild(EntitySpec.create(VanillaJavaApp.class)
.configure("main", "my.Main").configure("useJmx", false).configure("javaOpts", ImmutableList.of("-Xmx567m", "-XX:MaxPermSize=567m")));
app.start(ImmutableList.of(loc));
String runDir = javaProcess.getRunDir();
Object expectedJavaOpts = MutableSet.of("-Xms128m", "-Xmx567m", "-XX:MaxPermSize=567m");
Map<String,Object> expectedEnvs = ImmutableMap.<String,Object>of("JAVA_OPTS", expectedJavaOpts);
List<String> expectedCmds = ImmutableList.of(String.format("java $JAVA_OPTS -cp \"%1$s/lib\" my.Main >> %1$s/console 2>&1 </dev/null &", runDir));
assertHasExpectedCmds(expectedCmds, expectedEnvs);
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-utils-common
@Test
public void testJsonyaMaybe() {
Navigator<MutableMap<Object, Object>> m = europeMap();
Assert.assertEquals( m.at("europe", "spain", "barcelona").getMaybe().or("norealabc"), "norealabc" );
Assert.assertEquals(m.root().at("europe").getFocusMap().keySet(), MutableSet.of("uk", "france"));
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-core
@Test
public void testTagsFromSpec() throws Exception {
MyEnricher enricher = app.enrichers().add(EnricherSpec.create(MyEnricher.class).tag(99).uniqueTag("x"));
assertEquals(enricher.tags().getTags(), MutableSet.of("x", 99));
assertEquals(enricher.getUniqueTag(), "x");
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-core
@Test
public void testTagsFromSpec() throws Exception {
MyPolicy policy = app.policies().add(PolicySpec.create(MyPolicy.class).tag(99).uniqueTag("x"));
assertEquals(policy.tags().getTags(), MutableSet.of("x", 99));
assertEquals(policy.getUniqueTag(), "x");
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-core
@SuppressWarnings({ "unchecked", "rawtypes" })
public void testSetEmpty() throws Exception {
// ensure it is null before we pass something in, and passing an empty collection makes it be empty
log.info("Set-Empty-1: "+MutableMap.copyOf(entity.config().getLocalBag().getAllConfig()));
Assert.assertEquals(entity.getConfig(TestEntity.CONF_SET_THING), null);
entity.config().set((SetConfigKey)TestEntity.CONF_SET_THING, MutableSet.of());
log.info("Set-Empty-2: "+MutableMap.copyOf(entity.config().getLocalBag().getAllConfig()));
Assert.assertEquals(entity.getConfig(TestEntity.CONF_SET_THING), ImmutableSet.of());
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-launcher
@Test
public void testSelectionWithOrphanedLocationsInData() throws Exception {
final Set<String> orphanedLocations = MutableSet.of(
"msyp655po0",
"ppamsemxgo"
);
initManagementContextAndPersistence(persistenceDirWithOrphanedLocations);
BrooklynMementoRawData mementoRawData = mgmt.getRebindManager().retrieveMementoRawData();
assertTransformDeletes(new Deletions().locations(orphanedLocations), mementoRawData);
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-core
public void testCustomEntityRelation() {
TestEntity t1 = app.createAndManageChild(EntitySpec.create(TestEntity.class));
TestEntity t2 = app.createAndManageChild(EntitySpec.create(TestEntity.class));
t1.relations().add(EntityRelations.HAS_TARGET, t2);
Assert.assertEquals(t1.relations().getRelations(EntityRelations.HAS_TARGET), Collections.singleton(t2));
Assert.assertEquals(t2.relations().getRelations(EntityRelations.HAS_TARGET), Collections.emptySet());
Assert.assertEquals(t2.relations().getRelations(EntityRelations.TARGETTED_BY), Collections.singleton(t1));
t1.relations().add(EntityRelations.HAS_TARGET, t2);
Assert.assertEquals(t1.relations().getRelations(EntityRelations.HAS_TARGET), Collections.singleton(t2));
t1.relations().add(EntityRelations.HAS_TARGET, t1);
Assert.assertEquals(t1.relations().getRelations(EntityRelations.HAS_TARGET), MutableSet.of(t1, t2));
}
内容来源于网络,如有侵权,请联系作者删除!