@Override public PrismProperty<T> cloneComplex(CloneStrategy strategy) { PrismPropertyImpl<T> clone = new PrismPropertyImpl<>(getElementName(), getDefinition(), prismContext); copyValues(strategy, clone); return clone; }
public void addRealValues(T... valuesToAdd) { for (T valueToAdd : valuesToAdd) { addRealValue(valueToAdd); } }
public boolean deleteValues(Collection<PrismPropertyValue<T>> pValuesToDelete) { checkMutability(); boolean changed = false; for (PrismPropertyValue<T> pValue: pValuesToDelete) { if (!changed) { changed = deleteValue(pValue); } else { deleteValue(pValue); } } return changed; }
sb.append(getDebugDumpClassName()).append(": "); sb.append(DebugUtil.formatElementName(getElementName())).append(": "); PrismPropertyDefinition def = getDefinition(); if (def != null) { isMultivalue = def.isMultiValue(); List<PrismPropertyValue<T>> values = getValues(); if (values.isEmpty()) { sb.append("[]"); for (PrismPropertyValue<T> value: getValues()) { sb.append("\n"); if (value.isRaw()) { sb.append(formatRawValueForDump(value.getRawElement())); sb.append(" (raw)"); } else if (value.getExpression() != null) { } else { if (DebugUtil.isDetailedDebugDump()) { PrismPrettyPrinter.debugDumpValue(sb, indent + 1, realValue, prismContext, getElementName(), null); } else { sb.append("SS{"+realValue+"}"); Iterator<PrismPropertyValue<T>> iterator = getValues().iterator(); while (iterator.hasNext()) { PrismPropertyValue<T> value = iterator.next(); if (value.isRaw()) {
public boolean deleteValue(PrismPropertyValue<T> pValueToDelete) { checkMutability(); Iterator<PrismPropertyValue<T>> iterator = getValues().iterator(); boolean found = false; while (iterator.hasNext()) { PrismPropertyValue<T> pValue = iterator.next(); if (pValue.equals(pValueToDelete, EquivalenceStrategy.REAL_VALUE)) { iterator.remove(); pValue.setParent(null); found = true; } } if (!found) { LOGGER.warn("Deleting value of property "+ getElementName()+" that does not exist (skipping), value: "+pValueToDelete); } return found; }
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; }
@Override public PropertyDelta<T> createDelta() { return new PropertyDeltaImpl<>(getPath(), getDefinition(), prismContext); }
@Override public ResourceAttributeDefinition<T> getDefinition() { return (ResourceAttributeDefinition<T>) super.getDefinition(); }
protected void copyValues(CloneStrategy strategy, ResourceAttributeImpl<T> clone) { super.copyValues(strategy, clone); // Nothing to copy }
@Override public <T> PrismProperty<T> createProperty(QName itemName, PrismPropertyDefinition<T> definition) { return new PrismPropertyImpl<>(itemName, definition, prismContext); }
public void addValues(Collection<PrismPropertyValue<T>> pValuesToAdd) { if (pValuesToAdd == null) { return; } for (PrismPropertyValue<T> pValue: pValuesToAdd) { addValue(pValue); } }
/** * Sets applicable property definition. * * TODO remove (method in Item is sufficient) * @param definition the definition to set */ public void setDefinition(PrismPropertyDefinition<T> definition) { checkMutability(); this.definition = definition; }
@Override public PrismProperty<T> clone() { return cloneComplex(CloneStrategy.LITERAL); }
public void addValue(PrismPropertyValue<T> pValueToAdd) { checkMutability(); ((PrismPropertyValueImpl<T>) pValueToAdd).checkValue(); Iterator<PrismPropertyValue<T>> iterator = getValues().iterator(); while (iterator.hasNext()) { PrismPropertyValue<T> pValue = iterator.next(); if (pValue.equals(pValueToAdd, EquivalenceStrategy.REAL_VALUE)) { LOGGER.warn("Adding value to property "+ getElementName()+" that already exists (overwriting), value: "+pValueToAdd); iterator.remove(); } } pValueToAdd.setParent(this); pValueToAdd.recompute(); getValues().add(pValueToAdd); }
/** * 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(ItemPath path) { return new PropertyDeltaImpl<>(path, getDefinition(), prismContext); }