@Override public boolean containsAll(Collection<?> c) { return results.containsAll(c); }
/** Whether this node's graph is a super-set of (or equal to) another node's * graph. */ public boolean contains(LatticeRootNode node) { return paths.containsAll(node.paths); }
@Override public boolean containsAll(Collection<?> c) { return results.containsAll(c); }
@Override public boolean containsAll(Collection<?> targets) { return forwardList.containsAll(targets); }
@Override public boolean containsAll(Collection<?> targets) { return forwardList.containsAll(targets); }
@Override public boolean containsAll(Collection<?> targets) { return forwardList.containsAll(targets); }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (!(obj instanceof ListField<?>)) { return false; } ListField<?> other = (ListField<?>) obj; if (list == null) { if (other.list != null) return false; } else if (!(list.containsAll(other.list) & other.list.containsAll(list))) return false; return true; }
@Test public void testVisitWhile() { List<Long> longList = Lists.newArrayList(0L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L); BatchingVisitable<Long> visitable = ListVisitor.create(longList); BatchingVisitableView<Long> view = BatchingVisitables.visitWhile( BatchingVisitableView.of(visitable), (input) -> input.longValue() < 5L); assertEquals("visitWhile visited the wrong number of elements", 5L, view.size()); assertEquals("visitWhile visited the wrong element first", 0L, view.getFirst().longValue()); assertEquals("visitWhile visited the wrong element last", 4L, view.getLast().longValue()); assertTrue("visitWhile visited the wrong elements", view.immutableCopy().containsAll(ImmutableSet.of(0L, 1L, 2L, 3L, 4L))); visitable = ListVisitor.create(Lists.reverse(longList)); view = BatchingVisitables.visitWhile( BatchingVisitableView.of(visitable), (input) -> input.longValue() >= 5L); assertEquals("visitWhile visited the wrong number of elements", 5L, view.size()); assertEquals("visitWhile visited the wrong element first", 9L, view.getFirst().longValue()); assertEquals("visitWhile visited the wrong element last", 5L, view.getLast().longValue()); assertTrue("visitWhile visited the wrong elements", view.immutableCopy().containsAll(ImmutableSet.of(5L, 6L, 7L, 8L, 9L))); }
private int matchQuality(Lattice lattice, Lattice target) { if (!lattice.rootNode.table.equals(target.rootNode.table)) { return 0; } if (lattice.rootNode.paths.equals(target.rootNode.paths)) { return 3; } if (lattice.rootNode.paths.containsAll(target.rootNode.paths)) { return 2; } return 1; }
private boolean isRepresentableAsTernaryExpression(ImmutableList<IfThenPair> pairs) { if (pairs.size() != 1 || trailingElse == null) { return false; } IfThenPair ifThen = Iterables.getOnlyElement(pairs); CodeChunk.WithValue predicate = ifThen.predicate; CodeChunk consequent = ifThen.consequent; return consequent instanceof CodeChunk.WithValue && trailingElse instanceof CodeChunk.WithValue && predicate.initialStatements().containsAll(((WithValue) consequent).initialStatements()) && predicate .initialStatements() .containsAll(((WithValue) trailingElse).initialStatements()); } }
@Nullable private Expression tryCreateTernary(ImmutableList<IfThenPair<Expression>> pairs) { if (pairs.size() != 1 || trailingElse == null) { return null; } IfThenPair<Expression> ifThen = Iterables.getOnlyElement(pairs); Expression predicate = ifThen.predicate; Expression consequent = ifThen.consequent; // TODO(lukes): we could support nested ternaries with little additional difficulty if (predicate.initialStatements().containsAll(consequent.initialStatements()) && predicate.initialStatements().containsAll(trailingElse.initialStatements())) { return Ternary.create(predicate, consequent, trailingElse); } return null; }
/** * @return <code>true</code> if <code>call</code> is compatible with this pedigree */ private boolean isCompatibleWithPedigree(GenotypeCalls calls) { return pedigree.getNames().containsAll(calls.getSampleNames()); }
NominalType(ImmutableMap<String, JSType> typeMap, RawNominalType rawType) { Preconditions.checkState(typeMap.isEmpty() || typeMap.keySet().containsAll(rawType.getTypeParameters()) && rawType.getTypeParameters().containsAll(typeMap.keySet())); this.typeMap = typeMap; this.rawType = rawType; }
static Ternary create(Expression predicate, Expression consequent, Expression alternate) { Preconditions.checkArgument( predicate.initialStatements().containsAll(consequent.initialStatements())); Preconditions.checkArgument( predicate.initialStatements().containsAll(alternate.initialStatements())); return new AutoValue_Ternary( ImmutableList.<Statement>builder() .addAll(predicate.initialStatements()) .addAll(consequent.initialStatements()) .addAll(alternate.initialStatements()) .build(), predicate, consequent, alternate); }
@Test public void testHasAvailabilityZonesAsSubLocations() throws Exception { multiLoc.hasExtension(AvailabilityZoneExtension.class); AvailabilityZoneExtension extension = multiLoc.getExtension(AvailabilityZoneExtension.class); Asserts.assertEqualsIgnoringOrder(extension.getAllSubLocations(), ImmutableList.of(loc1, loc2)); Asserts.assertEqualsIgnoringOrder(extension.getSubLocations(2), ImmutableList.of(loc1, loc2)); assertTrue(ImmutableList.of(loc1, loc2).containsAll(extension.getSubLocations(1))); }
static CodeChunk.WithValue and( CodeChunk.WithValue lhs, CodeChunk.WithValue rhs, CodeChunk.Generator codeGenerator) { // If rhs has no initial statements, use the JS && operator directly. // It's already short-circuiting. if (lhs.initialStatements().containsAll(rhs.initialStatements())) { return create("&&", Operator.AND.getPrecedence(), Operator.AND.getAssociativity(), lhs, rhs); } // Otherwise, generate explicit short-circuiting code. // rhs should be evaluated only if lhs evaluates to true. CodeChunk.WithValue tmp = codeGenerator.declarationBuilder().setRhs(lhs).build().ref(); return Composite.create( ImmutableList.of(CodeChunk.ifStatement(tmp, tmp.assign(rhs)).build()), tmp); }
static Expression and(Expression lhs, Expression rhs, CodeChunk.Generator codeGenerator) { // If rhs has no initial statements, use the JS && operator directly. // It's already short-circuiting. if (lhs.initialStatements().containsAll(rhs.initialStatements())) { return create("&&", Operator.AND.getPrecedence(), Operator.AND.getAssociativity(), lhs, rhs); } // Otherwise, generate explicit short-circuiting code. // rhs should be evaluated only if lhs evaluates to true. Expression tmp = codeGenerator.declarationBuilder().setRhs(lhs).build().ref(); return Composite.create( ImmutableList.of(Statement.ifStatement(tmp, tmp.assign(rhs).asStatement()).build()), tmp); }
static CodeChunk.WithValue or( CodeChunk.WithValue lhs, CodeChunk.WithValue rhs, CodeChunk.Generator codeGenerator) { // If rhs has no initial statements, use the JS || operator directly. // It's already short-circuiting. if (lhs.initialStatements().containsAll(rhs.initialStatements())) { return create("||", Operator.OR.getPrecedence(), Operator.OR.getAssociativity(), lhs, rhs); } // Otherwise, generate explicit short-circuiting code. // rhs should be evaluated only if lhs evaluates to false. CodeChunk.WithValue tmp = codeGenerator.declarationBuilder().setRhs(lhs).build().ref(); return Composite.create( ImmutableList.of(CodeChunk.ifStatement(not(tmp), tmp.assign(rhs)).build()), tmp); }
static Expression or(Expression lhs, Expression rhs, CodeChunk.Generator codeGenerator) { // If rhs has no initial statements, use the JS || operator directly. // It's already short-circuiting. if (lhs.initialStatements().containsAll(rhs.initialStatements())) { return create("||", Operator.OR.getPrecedence(), Operator.OR.getAssociativity(), lhs, rhs); } // Otherwise, generate explicit short-circuiting code. // rhs should be evaluated only if lhs evaluates to false. Expression tmp = codeGenerator.declarationBuilder().setRhs(lhs).build().ref(); return Composite.create( ImmutableList.of(Statement.ifStatement(not(tmp), tmp.assign(rhs).asStatement()).build()), tmp); }
@Test(groups = "live", dependsOnMethods = "testListInstance") public void testSetTagsForInstance() { Instance originalInstance = api().get(INSTANCE_NAME); assertOperationDoneSuccessfully( api().setTags(INSTANCE_NAME, TAGS, originalInstance.tags().fingerprint())); Instance modifiedInstance = api().get(INSTANCE_NAME); assertTrue(modifiedInstance.tags().items().containsAll(TAGS)); assertNotNull(modifiedInstance.tags().fingerprint()); }