@Test public void testApplyWithMap() { Resource resource = new ResourceImpl(Resource.Type.HostComponent); String propertyId = PropertyHelper.getPropertyId("category1", "mapProperty"); Predicate predicate = new CategoryIsEmptyPredicate(propertyId); Assert.assertTrue(predicate.evaluate(resource)); Map<String, String> mapProperty = new HashMap<String, String>(); resource.setProperty(propertyId, mapProperty); Assert.assertTrue(predicate.evaluate(resource)); mapProperty.put("foo", "bar"); Assert.assertFalse(predicate.evaluate(resource)); }
@Override public boolean evaluate(Resource resource) { String propertyId = getPropertyId(); Object value = resource.getPropertyValue(propertyId); if (value instanceof Map) { Map<?,?> mapValue = (Map) value; return mapValue.isEmpty(); } Map<String, Object> properties = resource.getPropertiesMap().get(propertyId); return properties == null ? true : properties.isEmpty(); }
CategoryIsEmptyPredicate extends CategoryPredicate { @Override public boolean evaluate(Resource resource) { String propertyId = getPropertyId(); Object value = resource.getPropertyValue(propertyId); if (value instanceof Map) { Map<?,?> mapValue = (Map) value; return mapValue.isEmpty(); } Map<String, Object> properties = resource.getPropertiesMap().get(propertyId); return properties == null ? true : properties.isEmpty(); } }
CategoryIsEmptyPredicate extends CategoryPredicate { @Override public boolean evaluate(Resource resource) { String propertyId = getPropertyId(); Object value = resource.getPropertyValue(propertyId); if (value instanceof Map) { Map<?,?> mapValue = (Map) value; return mapValue.isEmpty(); } Map<String, Object> properties = resource.getPropertiesMap().get(propertyId); return properties == null ? true : properties.isEmpty(); } CategoryIsEmptyPredicate(String propertyId); }
CategoryIsEmptyPredicate extends CategoryPredicate { @Override public boolean evaluate(Resource resource) { String propertyId = getPropertyId(); Object value = resource.getPropertyValue(propertyId); if (value instanceof Map) { Map<?,?> mapValue = (Map) value; return mapValue.isEmpty(); } Map<String, Object> properties = resource.getPropertiesMap().get(propertyId); return properties == null ? true : properties.isEmpty(); } CategoryIsEmptyPredicate(String propertyId); @Override boolean evaluate(Resource resource); @Override String toString(); }
CategoryIsEmptyPredicate extends CategoryPredicate { @Override public boolean evaluate(Resource resource) { String propertyId = getPropertyId(); Object value = resource.getPropertyValue(propertyId); if (value instanceof Map) { Map<?,?> mapValue = (Map) value; return mapValue.isEmpty(); } Map<String, Object> properties = resource.getPropertiesMap().get(propertyId); return properties == null ? true : properties.isEmpty(); } CategoryIsEmptyPredicate(String propertyId); @Override boolean evaluate(Resource resource); @Override String toString();  }