@Test public void testApply() { Resource resource = new ResourceImpl(Resource.Type.HostComponent); String propertyId = PropertyHelper.getPropertyId("category1", "foo"); Predicate predicate = new EqualsPredicate<String>(propertyId, "bar"); resource.setProperty(propertyId, "monkey"); Assert.assertFalse(predicate.evaluate(resource)); resource.setProperty(propertyId, "bar"); Assert.assertTrue(predicate.evaluate(resource)); propertyId = PropertyHelper.getPropertyId("category1", "fun"); predicate = new EqualsPredicate<String>(propertyId, "bar"); Assert.assertFalse(predicate.evaluate(resource)); }
@Override public boolean evaluate(Resource resource) { Object propertyValue = resource.getPropertyValue(getPropertyId()); Object predicateValue = getValue(); return predicateValue == null ? propertyValue == null : propertyValue != null && compareValueTo(propertyValue) == 0; }
EqualsPredicate extends ComparisonPredicate<T> { @Override public boolean evaluate(Resource resource) { Object propertyValue = resource.getPropertyValue(getPropertyId()); Object predicateValue = getValue(); return predicateValue == null ? propertyValue == null : propertyValue != null && compareValueTo(propertyValue) == 0; } }
EqualsPredicate extends ComparisonPredicate<T> { @Override public boolean evaluate(Resource resource) { Object propertyValue = resource.getPropertyValue(getPropertyId()); Object predicateValue = getValue(); return predicateValue == null ? propertyValue == null : propertyValue != null && compareValueTo(propertyValue) == 0; } EqualsPredicate(String propertyId, Comparable<T> value); }
EqualsPredicate extends ComparisonPredicate<T> { @Override public boolean evaluate(Resource resource) { Object propertyValue = resource.getPropertyValue(getPropertyId()); Object predicateValue = getValue(); return predicateValue == null ? propertyValue == null : propertyValue != null && compareValueTo(propertyValue) == 0; } EqualsPredicate(String propertyId, Comparable<T> value); @Override boolean evaluate(Resource resource); boolean evaluateIgnoreCase(Resource resource); @Override String getOperator(); @Override ComparisonPredicate<T> copy(String propertyId); }
EqualsPredicate extends ComparisonPredicate<T> { @Override public boolean evaluate(Resource resource) { Object propertyValue = resource.getPropertyValue(getPropertyId()); Object predicateValue = getValue(); return predicateValue == null ? propertyValue == null : propertyValue != null && compareValueTo(propertyValue) == 0; } EqualsPredicate(String propertyId, Comparable<T> value); @Override boolean evaluate(Resource resource); boolean evaluateIgnoreCase(Resource resource); @Override String getOperator(); @Override ComparisonPredicate<T> copy(String propertyId);  }