@Test public void testApply() { Resource resource = new ResourceImpl(Resource.Type.HostComponent); String propertyId1 = PropertyHelper.getPropertyId("category1", "property1"); String propertyId2 = PropertyHelper.getPropertyId("category1", "property2"); String propertyId3 = PropertyHelper.getPropertyId("category1", "property3"); EqualsPredicate predicate1 = new EqualsPredicate<String>(propertyId1, "v1"); EqualsPredicate predicate2 = new EqualsPredicate<String>(propertyId2, "v2"); EqualsPredicate predicate3 = new EqualsPredicate<String>(propertyId3, "v3"); AndPredicate andPredicate = new AndPredicate(predicate1, predicate2, predicate3); resource.setProperty(propertyId1, "v1"); resource.setProperty(propertyId2, "monkey"); resource.setProperty(propertyId3, "v3"); Assert.assertFalse(andPredicate.evaluate(resource)); resource.setProperty(propertyId2, "v2"); Assert.assertTrue(andPredicate.evaluate(resource)); }
@Override public boolean evaluate(Resource resource) { Predicate[] predicates = getPredicates(); for (Predicate predicate : predicates) { if (!predicate.evaluate(resource)) { return false; } } return true; }
AndPredicate extends ArrayPredicate { @Override public boolean evaluate(Resource resource) { Predicate[] predicates = getPredicates(); for (Predicate predicate : predicates) { if (!predicate.evaluate(resource)) { return false; } } return true; } }
AndPredicate extends ArrayPredicate { @Override public boolean evaluate(Resource resource) { Predicate[] predicates = getPredicates(); for (Predicate predicate : predicates) { if (!predicate.evaluate(resource)) { return false; } } return true; } AndPredicate(Predicate... predicates); }
AndPredicate extends ArrayPredicate { @Override public boolean evaluate(Resource resource) { Predicate[] predicates = getPredicates(); for (Predicate predicate : predicates) { if (!predicate.evaluate(resource)) { return false; } } return true; } AndPredicate(Predicate... predicates); @Override Predicate create(Predicate... predicates); static Predicate instance(Predicate... predicates); @Override boolean evaluate(Resource resource); @Override String getOperator(); }
AndPredicate extends ArrayPredicate { @Override public boolean evaluate(Resource resource) { Predicate[] predicates = getPredicates(); for (Predicate predicate : predicates) { if (!predicate.evaluate(resource)) { return false; } } return true; } AndPredicate(Predicate... predicates); @Override Predicate create(Predicate... predicates); static Predicate instance(Predicate... predicates); @Override boolean evaluate(Resource resource); @Override String getOperator();  }