/** * Type override, also for compatibility. */ public <X> List<PrismPropertyValue<X>> getValues(Class<X> type) { return (List) getValues(); }
/** * Type override, also for compatibility. */ public <X> X[] getRealValuesArray(Class<X> type) { X[] valuesArrary = (X[]) Array.newInstance(type, getValues().size()); for (int j = 0; j < getValues().size(); ++j) { Object avalue = getValues().get(j).getValue(); Array.set(valuesArrary, j, avalue); } return valuesArrary; }
public boolean hasRealValue(PrismPropertyValue<T> value) { for (PrismPropertyValue<T> propVal : getValues()) { if (propVal.equals(value, EquivalenceStrategy.REAL_VALUE)) { return true; } } return false; }
/** * 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; }
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(); }
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; }
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); }
protected void copyValues(CloneStrategy strategy, PrismPropertyImpl<T> clone) { super.copyValues(strategy, clone); for (PrismPropertyValue<T> value : getValues()) { clone.addValue(value.cloneComplex(strategy)); } }
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 <IV extends PrismValue,ID extends ItemDefinition> PartiallyResolvedItem<IV,ID> findPartial(ItemPath path) { if (path == null || path.isEmpty()) { return new PartiallyResolvedItem<>((Item<IV, ID>) this, null); } for (PrismPropertyValue<T> pvalue: getValues()) { T value = pvalue.getValue(); if (!(value instanceof Structured)) { throw new IllegalArgumentException("Attempt to resolve sub-path '"+path+"' on non-structured property value "+pvalue); } } return new PartiallyResolvedItem<>((Item<IV, ID>) this, path); }
@Override public String toString() { return getDebugDumpClassName() + "(" + PrettyPrinter.prettyPrint(getElementName()) + "):" + getValues(); }
List<PrismPropertyValue<T>> values = getValues(); if (values.isEmpty()) { sb.append("[]"); for (PrismPropertyValue<T> value: getValues()) { sb.append("\n"); if (value.isRaw()) { sb.append("[ "); Iterator<PrismPropertyValue<T>> iterator = getValues().iterator(); while (iterator.hasNext()) { PrismPropertyValue<T> value = iterator.next();