public <IV extends PrismValue,ID extends ItemDefinition> Item<IV,ID> getParsedItem(ID itemDefinition, QName itemName) throws SchemaException { Validate.notNull(itemDefinition); Validate.notNull(itemName); Item<IV,ID> item = itemDefinition.instantiate(); IV newValue = getParsedValue(itemDefinition, itemName); if (newValue != null) { item.add((IV) newValue.clone()); } return item; }
private <V extends PrismValue, D extends ItemDefinition> void addItemValueIfPossible(Item<V, D> item, V value, ParsingContext pc) throws SchemaException { if (value != null) { try { item.add(value); } catch (SchemaException e) { pc.warnOrThrow(LOGGER, "Couldn't add a value of " + value + " to the containing item: " + e.getMessage(), e); } } }
private static void addRealValue(Item<PrismValue, ItemDefinition> extensionItem, Object value, PrismContext prismContext) throws SchemaException { if (value != null) { extensionItem.add(prismContext.itemFactory().createValue(value).clone()); } }
@NotNull Item getFilterItem() throws SchemaException { if (getDefinition() == null){ throw new SchemaException("Could not find definition for item " + getPath()); } Item filterItem = getDefinition().instantiate(); if (getValues() != null && !getValues().isEmpty()) { try { for (PrismValue v : getValues()){ filterItem.add(v.clone()); } } catch (SchemaException e) { throw new IllegalArgumentException(e.getMessage(), e); } } return filterItem; }
/** * Merges the provided item into this item. The values are joined together. * Returns true if new item or value was added. */ public <IV extends PrismValue,ID extends ItemDefinition> boolean merge(Item<IV,ID> item) throws SchemaException { checkMutability(); Item<IV, ID> existingItem = findItem(item.getElementName(), Item.class); if (existingItem == null) { return add(item); } else { boolean changed = false; for (IV newVal: item.getValues()) { if (existingItem.add((IV) newVal.clone())) { changed = true; } } return changed; } }
item.add(valueToAdd.clone(), false);
shouldBeItem.add(LensUtil.cloneAndApplyMetadata(itemWithOrigin.getItemValue(), isAssignment, shouldBeItemValues));