@Override public ResourceAttributeDefinition<T> getDefinition() { return (ResourceAttributeDefinition<T>) super.getDefinition(); }
@Override public PropertyDelta<T> createDelta(ItemPath path) { return new PropertyDeltaImpl<>(path, getDefinition(), prismContext); }
public Class<T> getValueClass() { if (getDefinition() != null) { return getDefinition().getTypeClass(); } if (!getValues().isEmpty()) { PrismPropertyValue<T> firstPVal = getValues().get(0); if (firstPVal != null) { T firstVal = firstPVal.getValue(); if (firstVal != null) { return (Class<T>) firstVal.getClass(); } } } // TODO: How to determine value class????? return PrismConstants.DEFAULT_VALUE_CLASS; }
/** * Type override, also for compatibility. */ public <X> PrismPropertyValue<X> getValue(Class<X> type) { if (getDefinition() != null) { if (getDefinition().isMultiValue()) { throw new IllegalStateException("Attempt to get single value from property " + elementName + " with multiple values"); } } if (getValues().size() > 1) { throw new IllegalStateException("Attempt to get single value from property " + elementName + " with multiple values"); } if (getValues().isEmpty()) { return null; } PrismPropertyValue<X> o = (PrismPropertyValue<X>) getValues().iterator().next(); return o; }
@Override public PropertyDelta<T> createDelta() { return new PropertyDeltaImpl<>(getPath(), getDefinition(), prismContext); }
@Override public PrismProperty<T> cloneComplex(CloneStrategy strategy) { PrismPropertyImpl<T> clone = new PrismPropertyImpl<>(getElementName(), getDefinition(), prismContext); copyValues(strategy, clone); return clone; }
@Override protected ItemDelta fixupDelta(ItemDelta delta, Item otherItem) { PrismPropertyDefinition def = getDefinition(); if (def != null && def.isSingleValue() && !delta.isEmpty()) { // Drop the current delta (it was used only to detect that something has changed // Generate replace delta instead of add/delete delta PrismProperty<T> other = (PrismProperty<T>)otherItem; PropertyDelta<T> propertyDelta = (PropertyDelta<T>)delta; delta.clear(); Collection<PrismPropertyValue<T>> replaceValues = new ArrayList<>(other.getValues().size()); for (PrismPropertyValue<T> value : other.getValues()) { replaceValues.add(value.clone()); } propertyDelta.setValuesToReplace(replaceValues); return propertyDelta; } else { return super.fixupDelta(delta, otherItem); } }
PrismPropertyDefinition def = getDefinition(); if (def != null) { isMultivalue = def.isMultiValue();