本文整理了Java中com.evolveum.midpoint.prism.Item.getValues()
方法的一些代码示例,展示了Item.getValues()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Item.getValues()
方法的具体详情如下:
包路径:com.evolveum.midpoint.prism.Item
类名称:Item
方法名:getValues
暂无
代码示例来源:origin: Evolveum/midpoint
static boolean hasNoValues(Item<?, ?> item) {
return item == null || item.getValues().isEmpty();
}
代码示例来源:origin: Evolveum/midpoint
private int getValueCount(Object item) {
if (item == null) {
return 0;
}
if (!(item instanceof Item)) {
throw new IllegalStateException("Expected Item but got " + item.getClass() + " instead");
}
return ((Item) item).getValues().size();
}
代码示例来源:origin: Evolveum/midpoint
@NotNull
static <V extends PrismValue> Collection<V> getValues(Item<V, ?> item) {
return item != null ? item.getValues() : Collections.emptySet();
}
代码示例来源:origin: Evolveum/midpoint
@NotNull
private static List<PrismValue> getValues(PrismContainerValue<?> pcv, ItemPath path) {
Item<PrismValue, ItemDefinition> item = pcv.findItem(path);
return item != null ? item.getValues() : Collections.emptyList();
}
代码示例来源:origin: Evolveum/midpoint
@Nullable
private <IV extends PrismValue> IV getSingleParentlessValue(Item<IV, ?> item) {
if (item.size() == 0) {
return null;
} else if (item.size() == 1) {
IV value = item.getValues().get(0);
value.setParent(null);
return value;
} else {
throw new IllegalStateException("Expected one item value, got " + item.getValues().size()
+ " while parsing " + item);
}
}
代码示例来源:origin: Evolveum/midpoint
@Override
public Object get(int index) {
if (isSchemaless()) {
throw new UnsupportedOperationException("Definition-less containers are not supported any more.");
} else {
if (containerValue != null) {
for (Item<?,?> item : containerValue.getItems()) {
if (index < item.getValues().size()) {
return asElement(item.getValues().get(index));
} else {
index -= item.getValues().size();
}
}
throw new IndexOutOfBoundsException();
}
return null; //TODO: is this OK??
}
}
代码示例来源:origin: Evolveum/midpoint
@Override
public Object remove(int index) {
if (isSchemaless()) {
throw new UnsupportedOperationException("Definition-less containers are not supported any more.");
} else {
for (Item<?,?> item: containerValue.getItems()) {
if (index < item.getValues().size()) {
((ItemImpl) item).remove(index);
} else {
index -= item.getValues().size();
}
}
throw new IndexOutOfBoundsException();
}
}
代码示例来源:origin: Evolveum/midpoint
public static String prettyPrint(Item<?, ?> item) {
String values = item.getValues().stream()
.map(value -> PrettyPrinter.prettyPrint(value))
.collect(Collectors.joining(", "));
return PrettyPrinter.prettyPrint(item.getElementName()) + "={" + values + "}";
}
代码示例来源:origin: Evolveum/midpoint
private Collection findItemValues(Long id, ItemPath path, Collection<PrismContainerValue<V>> cvalues) {
if (cvalues == null) {
return null;
}
boolean foundValuesOnPath = false;
Collection<PrismValue> subValues = new ArrayList<>();
for (PrismContainerValue<V> cvalue: cvalues) {
if (id == null || id.equals(cvalue.getId())) {
Item<?,?> item = cvalue.findItem(path);
if (item != null) {
subValues.addAll(PrismValueCollectionsUtil.cloneCollection(item.getValues()));
foundValuesOnPath = true;
}
}
}
return foundValuesOnPath ? subValues : null;
}
代码示例来源:origin: Evolveum/midpoint
@Override
public Long getAssignmentId() {
Item<PrismContainerValue<AssignmentType>, PrismContainerDefinition<AssignmentType>> any = assignmentIdi.getAnyItem();
return any != null && !any.getValues().isEmpty() ? any.getAnyValue().getId() : null;
}
代码示例来源:origin: Evolveum/midpoint
@Override
public <T extends Containerable> T getExtensionContainerRealValue(QName containerName) {
Item<?, ?> item = getExtensionItem(ItemName.fromQName(containerName));
if (item == null || item.getValues().isEmpty()) {
return null;
} else {
return ((PrismContainer<T>) item).getRealValue();
}
}
代码示例来源:origin: Evolveum/midpoint
/**
* Merge all the values of other item to this item.
*/
@Override
public void merge(Item<V,D> otherItem) throws SchemaException {
for (V otherValue: otherItem.getValues()) {
if (!contains(otherValue)) {
add((V) otherValue.clone());
}
}
}
代码示例来源:origin: Evolveum/midpoint
private Item parseItem(RootXNodeImpl root, QName itemName, ItemDefinition itemDefinition) throws SchemaException{
Item<?,?> item;
item = prismContext.parserFor(root)
.name(itemName)
.definition(itemDefinition)
.context(prismContext.createParsingContextForAllowMissingRefTypes())
.parseItem();
if (item.getValues().size() < 1 ) {
throw new IllegalStateException("No values to search specified for item " + itemName);
}
return item;
}
代码示例来源:origin: Evolveum/midpoint
public static <IV extends PrismValue,ID extends ItemDefinition> List<JAXBElement<RawType>> serializeValueElements(Item<IV,ID> item, String contextDescription) throws SchemaException {
if (item == null) {
return null;
}
List<JAXBElement<RawType>> elements = new ArrayList<>(item.size());
for (PrismValue value : item.getValues()) {
RootXNode xnode = item.getPrismContext().xnodeSerializer().serialize(value);
RawType rawType = new RawType(xnode.getSubnode(), item.getPrismContext());
JAXBElement<RawType> jaxbElement = new JAXBElement<>(SchemaConstants.C_VALUE, RawType.class, rawType);
elements.add(jaxbElement);
}
return elements;
}
代码示例来源:origin: Evolveum/midpoint
public static <O extends Objectable> void setDeltaOldValue(PrismObject<O> oldObject, ItemDelta<?,?> itemDelta) {
if (oldObject == null) {
return;
}
Item<PrismValue, ItemDefinition> itemOld = oldObject.findItem(itemDelta.getPath());
if (itemOld != null) {
itemDelta.setEstimatedOldValues((Collection) PrismValueCollectionsUtil.cloneCollection(itemOld.getValues()));
}
}
代码示例来源:origin: Evolveum/midpoint
public static void assertParentConsistency(Item<?,?> item) {
for (PrismValue pval: item.getValues()) {
assert pval.getParent() == item : "Wrong parent of "+pval+" in "+PrettyPrinter.prettyPrint(item.getElementName());
if (pval instanceof PrismContainerValue) {
assertParentConsistency((PrismContainerValue)pval);
}
}
}
代码示例来源:origin: Evolveum/midpoint
public static <IV extends PrismValue,ID extends ItemDefinition> PrismValueDeltaSetTriple<IV> toDeltaSetTriple(
Item<IV, ID> item,
ItemDelta<IV, ID> delta, PrismContext prismContext) {
if (item == null && delta == null) {
return null;
}
if (delta == null) {
PrismValueDeltaSetTriple<IV> triple = prismContext.deltaFactory().createPrismValueDeltaSetTriple();
triple.addAllToZeroSet(PrismValueCollectionsUtil.cloneCollection(item.getValues()));
return triple;
}
return delta.toDeltaSetTriple(item);
}
代码示例来源:origin: Evolveum/midpoint
public boolean isRedundant(PrismObject<? extends Objectable> object, Comparator<V> comparator) {
Item<V,D> currentItem = (Item<V,D>) object.findItem(getPath());
if (currentItem == null) {
if (valuesToReplace != null) {
return valuesToReplace.isEmpty();
}
return !hasAnyValue(valuesToAdd);
} else {
if (valuesToReplace != null) {
return MiscUtil.unorderedCollectionCompare(valuesToReplace, currentItem.getValues(), comparator);
}
ItemDeltaImpl<V,D> narrowed = (ItemDeltaImpl<V, D>) narrow(object, comparator);
boolean narrowedNotEmpty = narrowed == null || narrowed.hasAnyValue(narrowed.valuesToAdd) || narrowed.hasAnyValue(narrowed.valuesToDelete);
return narrowedNotEmpty;
}
}
代码示例来源:origin: Evolveum/midpoint
/**
* 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;
}
}
代码示例来源:origin: Evolveum/midpoint
private FactorOutResultMulti<O> factorOutValuesForAddDelta(ItemPath path, boolean cloneDelta) {
Item<?, ?> item = objectToAdd.findItem(path);
if (item == null || item.isEmpty()) {
return new FactorOutResultMulti<>(this);
}
ObjectDeltaImpl<O> remainder = cloneIfRequested(cloneDelta);
remainder.getObjectToAdd().remove(item);
FactorOutResultMulti<O> rv = new FactorOutResultMulti<>(remainder);
for (PrismValue value : item.getValues()) {
ObjectDeltaImpl<O> offspring = createOffspring();
offspring.addModification(ItemDeltaUtil.createAddDeltaFor(item, value));
rv.offsprings.add(offspring);
}
return rv;
}
内容来源于网络,如有侵权,请联系作者删除!