public List<Service> getServices() { return MutableList.copyOf(services).asUnmodifiable(); }
protected Object readResolve() { if (catalogItemIdSearchPath == null) { catalogItemIdSearchPath = MutableList.of(); } return this; }
public static List<Point> listOfIntegerCoords(Iterable<? extends Iterable<Integer>> points) { MutableList<Point> result = MutableList.of(); for (Iterable<Integer> point: points) result.add(ofIntegerCoords(point)); return result.asUnmodifiable(); } @Override
@Override protected List<Object> merge(boolean unmodifiable, Iterable<?>... sets) { MutableList<Object> result = MutableList.of(); for (Iterable<?> set: sets) result.addAll(set); if (unmodifiable) return result.asUnmodifiable(); return result; }
public static <V> MutableList<V> of(V v1) { MutableList<V> result = new MutableList<V>(); result.add(v1); return result; }
@Override protected Object compute() { synchronized (values) { // TODO Could avoid copying when filter not needed List<T> vs = MutableList.copyOf(Iterables.filter(values.values(), valueFilter)); if (transformation==null) return vs; return transformation.apply(vs); } }
private static void assertVersionOrder(String v1, String v2, String ...otherVersions) { List<String> versions = MutableList.<String>of().append(v1, v2, otherVersions); for (int i=0; i<versions.size(); i++) { for (int j=0; j<versions.size(); j++) { assertEquals(VersionComparator.getInstance().compare( versions.get(i), versions.get(j)), new Integer(i).compareTo(j), "comparing "+versions.get(i)+" and "+versions.get(j)); } } }
@Test public void testOrder() { ConfigBag bag = ConfigBag.newInstance(); bag.put(K1, "v1"); bag.put(K2, "v2"); bag.put(K3, "v3"); Assert.assertEquals(MutableList.copyOf(bag.getAllConfig().keySet()), MutableList.of(K1.getName(), K2.getName(), K3.getName())); Assert.assertEquals(MutableList.copyOf(bag.getAllConfig().values()), MutableList.of("v1", "v2", "v3")); }
public void testContainingNullAndUnmodifiable() { MutableList<Object> x = MutableList.<Object>of("x", null); Assert.assertTrue(x.contains(null)); List<Object> x1 = x.asUnmodifiable(); List<Object> x2 = x.asUnmodifiableCopy(); List<Object> x3 = x.asImmutableCopy(); x.remove(null); Assert.assertFalse(x.contains(null)); Assert.assertFalse(x1.contains(null)); Assert.assertTrue(x2.contains(null)); Assert.assertTrue(x3.contains(null)); try { x1.remove("x"); Assert.fail(); } catch (Exception e) { /* expected */ } try { x2.remove("x"); Assert.fail(); } catch (Exception e) { /* expected */ } try { x3.remove("x"); Assert.fail(); } catch (Exception e) { /* expected */ } Assert.assertTrue(x1.contains("x")); Assert.assertTrue(x2.contains("x")); Assert.assertTrue(x3.contains("x")); }
/** returns a "groupId:artifactId:version:(classifier:)packaging" string * which maven refers to as the co-ordinate */ public String getCoordinate() { return Strings.join(MutableList.<String>of().append(groupId, artifactId, packaging). appendIfNotNull(classifier).append(version), ":"); }
protected void applyToIterable() { MutableList<Object> input = MutableList.copyOf((Iterable<?>)originalValue); MutableList<Object> result = new MutableList<Object>(); newValue = result; // first do a "whole-node" application if (getContext().getAllInterpreter().applyListBefore(this, input)) { for (Object entry: input) { // then recurse in to this node and do various in-the-node applications PlanInterpretationNode value = newPlanInterpretation(this, Role.LIST_ENTRY, entry); value.apply(); if (value.isChanged()) changed = true; if (getContext().getAllInterpreter().applyListEntry(this, input, result, value)) result.add(value.getNewValue()); } // finally try applying to this node again getContext().getAllInterpreter().applyListAfter(this, input, result); } if (changed==null) changed = false; }
private List<?> mergeListsImpl(List<?> val1, Iterable<?> val2, int depthRemaining, Visited visited) { return MutableList.builder() .addAll(val1) .addAll(val2) .build(); }
/** creates the command for running knife. * in some cases knife may be added multiple times, * and in that case the parameter here tells which time it is being added, * on a single run. */ protected String buildKnifeCommand(int knifeCommandIndex) { MutableList<String> words = new MutableList<String>(); words.add(knifeExecutable()); words.addAll(initialKnifeParameters()); words.addAll(knifeParameters()); String x = knifeConfigFileOption(); if (Strings.isNonBlank(x)) words.add(knifeConfigFileOption()); return Strings.join(words, " "); }
private void addDeprecatedExtraServiceToExtraServices() { EntitySpec<? extends ExtraService> entitySpec = getConfig(EXTRA_HADOOP_SERVICE); if (entitySpec != null) { LOG.warn(EXTRA_HADOOP_SERVICE.getName() + " configuration key is deprecated. Extra services should now be defined through as children by using 'brooklyn.children'"); MutableList<EntitySpec<? extends ExtraService>> specs = MutableList.copyOf(getConfig(EXTRA_HADOOP_SERVICES)); specs.add(entitySpec); config().set(EXTRA_HADOOP_SERVICES, specs); } }
/** returns fields which should be used for equality, including by default {@link #toStringOtherFields()} and {@link #toStringPollSource()}; * subclasses can add to the returned value */ protected MutableList<Object> equalsFields() { MutableList<Object> result = MutableList.of().appendIfNotNull(getSensor()).appendIfNotNull(toStringPollSource()); for (Object field: toStringOtherFields()) result.appendIfNotNull(field); return result; }
@Override public List<String> getCommands() { MutableList<String> result = new MutableList<String>(); String setupCommands = knifeSetupCommands(); if (setupCommands != null && Strings.isNonBlank(setupCommands)) result.add(setupCommands); int numKnifes = 0; for (String c: super.getCommands()) { if (c==KNIFE_PLACEHOLDER) result.add(buildKnifeCommand(numKnifes++)); else result.add(c); } if (numKnifes==0) result.add(buildKnifeCommand(numKnifes++)); return result.asUnmodifiable(); }
public MutableList(Iterable<? extends V> source) { for (V s : source) { add(s); } }