@Test public void testApplyNullValue() { Resource resource = new ResourceImpl(Resource.Type.HostComponent); String propertyId = PropertyHelper.getPropertyId("category1", "foo"); Predicate predicate = new FilterPredicate(propertyId, null); resource.setProperty(propertyId, "monkey"); Assert.assertFalse(predicate.evaluate(resource)); resource.setProperty(propertyId, null); Assert.assertTrue(predicate.evaluate(resource)); }
@Override public boolean evaluate(Resource resource) { Object propertyValue = resource.getPropertyValue(getPropertyId()); matcher.reset(propertyValue != null ? propertyValue.toString() : emptyString); return patternExpr == null ? propertyValue == null : propertyValue != null && matcher.matches(); }
FilterPredicate extends ComparisonPredicate { @Override public boolean evaluate(Resource resource) { Object propertyValue = resource.getPropertyValue(getPropertyId()); matcher.reset(propertyValue != null ? propertyValue.toString() : emptyString); return patternExpr == null ? propertyValue == null : propertyValue != null && matcher.matches(); } }
FilterPredicate extends ComparisonPredicate { @Override public boolean evaluate(Resource resource) { Object propertyValue = resource.getPropertyValue(getPropertyId()); matcher.reset(propertyValue != null ? propertyValue.toString() : emptyString); return patternExpr == null ? propertyValue == null : propertyValue != null && matcher.matches(); } @SuppressWarnings("unchecked")  FilterPredicate(String propertyId, String patternExpr); }
FilterPredicate extends ComparisonPredicate { @Override public boolean evaluate(Resource resource) { Object propertyValue = resource.getPropertyValue(getPropertyId()); matcher.reset(propertyValue != null ? propertyValue.toString() : emptyString); return patternExpr == null ? propertyValue == null : propertyValue != null && matcher.matches(); } @SuppressWarnings("unchecked")  FilterPredicate(String propertyId, String patternExpr); @Override boolean evaluate(Resource resource); @Override String getOperator(); @Override ComparisonPredicate copy(String propertyId); @Override String toString(); }
FilterPredicate extends ComparisonPredicate { @Override public boolean evaluate(Resource resource) { Object propertyValue = resource.getPropertyValue(getPropertyId()); matcher.reset(propertyValue != null ? propertyValue.toString() : emptyString); return patternExpr == null ? propertyValue == null : propertyValue != null && matcher.matches(); } @SuppressWarnings("unchecked")  FilterPredicate(String propertyId, String patternExpr); @Override boolean evaluate(Resource resource); @Override String getOperator(); @Override ComparisonPredicate copy(String propertyId); @Override String toString();  }