protected LinearRangeQuorumCheck(String name, Iterable<Point> points) { Preconditions.checkArgument(Iterables.size(points)>=2, "At least two points must be supplied for "+name+": "+points); this.name = name; this.points = MutableList.copyOf(points).asUnmodifiable(); // check valid Point last = null; for (Point p: points) { if (last!=null) { if (p.size <= last.size) throw new IllegalStateException("Points must be supplied in order of increasing totalSize (x coordinate); instead have "+last+" and "+p); } } }
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")); }
public List<Artifact> getArtifacts() { return MutableList.copyOf(artifacts).asUnmodifiable(); }
public List<Service> getServices() { return MutableList.copyOf(services).asUnmodifiable(); }
@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 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 public List<Function<ProcessTaskWrapper<?>, Void>> getCompletionListeners() { MutableList<Function<ProcessTaskWrapper<?>, Void>> result = MutableList.copyOf(super.getCompletionListeners()); if (throwOnCommonKnifeErrors != Boolean.FALSE) insertKnifeCompletionListenerIntoCompletionListenersList(result); return result.asUnmodifiable(); }
@Override public List<Function<ProcessTaskWrapper<?>, Void>> getCompletionListeners() { MutableList<Function<ProcessTaskWrapper<?>, Void>> result = MutableList.copyOf(super.getCompletionListeners()); if (throwOnCommonKnifeErrors != Boolean.FALSE) insertKnifeCompletionListenerIntoCompletionListenersList(result); return result.asUnmodifiable(); }
/** * The {@link {@link Tasks#current()} for each call to {@link #onEvent(SensorEvent)} */ public List<Task<?>> getTasks() { return MutableList.copyOf(tasks).asUnmodifiable(); }
protected BasicDownloadTargets(Builder builder) { primaries = ImmutableList.copyOf(builder.primaries); fallbacks = MutableList.<String>builder().addAll(builder.fallbacks).removeAll(builder.primaries).build().asUnmodifiable(); canContinueResolving = builder.canContinueResolving; }
private static Object immutable(Object in) { if (in instanceof Map) return MutableMap.copyOf((Map<?,?>)in).asUnmodifiable(); if (in instanceof Iterable) return MutableList.copyOf((Iterable<?>)in).asUnmodifiable(); return in; }
private <T> List<T> getServiceStateEvents(RecordingSensorEventListener<T> listener) { if (stateListener == null) { return ImmutableList.of(); } else { return MutableList.copyOf(listener.getEventValues()).asUnmodifiable(); } }
.add(BrooklynTaskTags.SENSOR_TAG) .build() .asUnmodifiable();
@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(); }
@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(); }