public String toHumanReadableString() { StringBuilder sb = new StringBuilder(); sb.append(PrettyPrinter.prettyPrint(getElementName())).append(" = "); if (getValues() == null) { sb.append("null"); } else { sb.append("[ "); Iterator<PrismPropertyValue<T>> iterator = getValues().iterator(); while(iterator.hasNext()) { PrismPropertyValue<T> value = iterator.next(); sb.append(value.toHumanReadableString()); if (iterator.hasNext()) { sb.append(", "); } } sb.append(" ]"); } return sb.toString(); }
/** * Type override, also for compatibility. */ public <X> X getRealValue(Class<X> type) { if (getValue() == null) { return null; } X value = (X) getValue().getValue(); if (value == null) { return null; } if (type.isAssignableFrom(value.getClass())) { return (X)value; } else { throw new ClassCastException("Cannot cast value of property "+ getElementName()+" which is of type "+value.getClass()+" to "+type); } }
@Override public PrismProperty<T> cloneComplex(CloneStrategy strategy) { PrismPropertyImpl<T> clone = new PrismPropertyImpl<>(getElementName(), getDefinition(), prismContext); copyValues(strategy, clone); return clone; }
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; }
@Override public Object find(ItemPath path) { if (path == null || path.isEmpty()) { return this; } if (!isSingleValue()) { throw new IllegalStateException("Attempt to resolve sub-path '"+path+"' on multi-value property " + getElementName()); } PrismPropertyValue<T> value = getValue(); return value.find(path); }
@Override public String toString() { return getDebugDumpClassName() + "(" + PrettyPrinter.prettyPrint(getElementName()) + "):" + getValues(); }
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); }
sb.append(getDebugDumpClassName()).append(": "); sb.append(DebugUtil.formatElementName(getElementName())).append(": "); } else { if (DebugUtil.isDetailedDebugDump()) { PrismPrettyPrinter.debugDumpValue(sb, indent + 1, realValue, prismContext, getElementName(), null); } else { sb.append("SS{"+realValue+"}"); T realValue = value.getValue(); if (DebugUtil.isDetailedDebugDump()) { PrismPrettyPrinter.debugDumpValue(sb, indent + 1, realValue, prismContext, getElementName(), null); } else { PrettyPrinter.shortDump(sb, realValue);