public boolean isEmpty() { for (PrismContainerValue<C> pval : getValues()) { if (!pval.isEmpty()) { return false; } } return true; }
/** * Remove all empty values */ public void trim() { Iterator<PrismContainerValue<C>> iterator = getValues().iterator(); while (iterator.hasNext()) { PrismContainerValue<C> pval = iterator.next(); if (pval.isEmpty()) { checkMutability(); iterator.remove(); } } }
@Override public int size() { if (isSchemaless()) { throw new UnsupportedOperationException("Definition-less containers are not supported any more."); } else { // Each item and each value are presented as one list entry // (multi-valued items are represented as multiple occurrences of the same element) int size = 0; if (containerValue.isEmpty()){ return size; } for (Item<?,?> item: containerValue.getItems()) { size += item.getValues().size(); } return size; } }
public PrismContainerValueAsserter<C,RA> assertAny() { assertNotNull("No container value in "+desc(), getPrismValue()); assertFalse("No items in "+desc(), getPrismValue().isEmpty()); return this; }
public ShadowAttributesAsserter<R> assertAny() { assertNotNull("No attributes container in "+desc(), getAttributesContainer()); PrismContainerValue<ShadowAttributesType> containerValue = getAttributesContainer().getValue(); assertNotNull("No attributes container avlue in "+desc(), containerValue); assertFalse("No attributes in "+desc(), containerValue.isEmpty()); return this; }
if (assignmentCVal.isEmpty()) { if (assignmentCVal.getId() != null) { element = idMap.get(assignmentCVal.getId());
private void assertMetaroleJaxb(RoleType roleType, boolean isObject) throws SchemaException { assertEquals("Wrong name", PrismTestUtil.createPolyStringType("Generic Metarole"), roleType.getName()); boolean found = false; for (AssignmentType inducement : roleType.getInducement()) { if (inducement.getId() == 2L) { found = true; PolicyRuleType rule = inducement.getPolicyRule(); assertNotNull("No constraints", rule.getPolicyConstraints()); assertEquals("Wrong # of assignment constraints", 1, rule.getPolicyConstraints().getAssignment().size()); assertTrue("Wrong (not empty) assignment constraints", rule.getPolicyConstraints().getAssignment().get(0).asPrismContainerValue().isEmpty()); break; } } assertTrue("Assignment number 2 was not found", found); }
private void assertMetarolePrism(PrismObject<RoleType> metarole, boolean isObject) { if (isObject) { assertEquals("Wrong oid", "12345678-d34d-b33f-f00d-55555555a020", metarole.getOid()); } PrismObjectDefinition<RoleType> usedDefinition = metarole.getDefinition(); assertNotNull("No metarole definition", usedDefinition); PrismAsserts.assertObjectDefinition(usedDefinition, new QName(SchemaConstantsGenerated.NS_COMMON, "role"), RoleType.COMPLEX_TYPE, RoleType.class); assertEquals("Wrong class in role", RoleType.class, metarole.getCompileTimeClass()); RoleType roleType = metarole.asObjectable(); assertNotNull("asObjectable resulted in null", roleType); assertPropertyValue(metarole, "name", PrismTestUtil.createPolyString("Generic Metarole")); assertPropertyDefinition(metarole, "name", PolyStringType.COMPLEX_TYPE, 0, 1); PrismContainer<?> assignmentConstraints = metarole.findContainer( ItemPath.create(RoleType.F_INDUCEMENT, 2L, AssignmentType.F_POLICY_RULE, PolicyRuleType.F_POLICY_CONSTRAINTS, PolicyConstraintsType.F_ASSIGNMENT)); assertNotNull("No assignment constraints", assignmentConstraints); assertEquals("Wrong # of assignment constraints", 1, assignmentConstraints.size()); assertTrue("Wrong (not empty) assignment constraints", assignmentConstraints.getValues().get(0).isEmpty()); }