public static PrismReference getReference(PrismContainerValue parent, QName fieldName) { try { PrismReference reference = parent.findReference(fieldName); if (reference != null) { return reference; } else { return (PrismReference) parent.createDetachedSubItem(fieldName, PrismReferenceImpl.class, null, parent.isImmutable()); } } catch (SchemaException e) { // This should not happen. Code generator and compiler should take care of that. throw new IllegalStateException("Internal schema error: "+e.getMessage(),e); } }
public static <T extends PrismContainer<?>> T getContainer(PrismContainerValue parentValue, QName name) { Validate.notNull(parentValue, "Parent container value must not be null."); Validate.notNull(name, "QName must not be null."); try { PrismContainer container = parentValue.findContainer(name); if (container != null) { return (T) container; } else { return (T) parentValue.createDetachedSubItem(name, PrismContainerImpl.class, null, parentValue.isImmutable()); } } catch (SchemaException ex) { throw new SystemException(ex.getMessage(), ex); } }
public static <T> List<T> getPropertyValues(PrismContainerValue<?> container, QName name, Class<T> clazz) { Validate.notNull(container, "Container must not be null."); Validate.notNull(name, "QName must not be null."); Validate.notNull(clazz, "Class type must not be null."); PrismProperty<?> property; try { property = container.findProperty(ItemName.fromQName(name)); if (property == null) { property = container.createDetachedSubItem(name, PrismPropertyImpl.class, null, container.isImmutable()); } } catch (SchemaException e) { // This should not happen. Code generator and compiler should take care of that. throw new IllegalStateException("Internal schema error: "+e.getMessage(),e); } return new PropertyArrayList<>(property, container); }