/** * Returns the value of the first segment if it is a variable name segment; otherwise null. */ default QName firstToVariableNameOrNull() { if (isEmpty()) { return null; } else { Object first = first(); return isVariable(first) ? toVariableName(first) : null; } }
/** * Returns true if the path starts with variable name ($...). */ default boolean startsWithVariable() { return !isEmpty() && ItemPath.isVariable(first()); }
private void add(Object component) { if (component instanceof ItemPath && !(component instanceof ItemName)) { addAll(((ItemPath) component).getSegments()); } else if (component instanceof Object[]) { addAll((Object[]) component); } else if (component instanceof String) { segments.add(new ItemName((String) component)); } else if (component != null) { segments.add(component); } else { segments.add(IdItemPathSegment.NULL); } }
/** * Returns true if the path starts with an object reference (@). */ default boolean startsWithObjectReference() { return !isEmpty() && ItemPath.isObjectReference(first()); }
protected ItemDeltaImpl(QName elementName, D itemDefinition, PrismContext prismContext) { //checkPrismContext(prismContext, itemDefinition); this.prismContext = prismContext; this.elementName = ItemName.fromQName(elementName); this.parentPath = ItemPath.EMPTY_PATH; this.definition = itemDefinition; }
public static ItemPathSegment createSegment(QName qname, boolean variable) { if (ParentPathSegment.QNAME.equals(qname)) { return new ParentPathSegment(); } else if (ObjectReferencePathSegment.QNAME.equals(qname)) { return new ObjectReferencePathSegment(); } else if (IdentifierPathSegment.QNAME.equals(qname)) { return new IdentifierPathSegment(); } else if (variable) { return new VariableItemPathSegment(qname); } else { return new NameItemPathSegment(qname); } }
public static boolean isAmongHiddenPaths(ItemPath path, List<ItemPath> hiddenPaths) { if (hiddenPaths == null) { return false; } for (ItemPath hiddenPath : hiddenPaths) { if (hiddenPath.isSubPathOrEquivalent(path)) { return true; } } return false; }
/** * Returns the remainder of "this" path after passing all segments from the other path. * (I.e. this path must begin with the content of the other path. Throws an exception when * it is not the case.) */ default ItemPath remainder(ItemPath path) { return ItemPathComparatorUtil.remainder(this, path); }
public IdItemPathSegment clone() { IdItemPathSegment clone = new IdItemPathSegment(); clone.id = this.id; return clone; }
/** * Check if the other path is a strict subpath (prefix) of this path. * The same as otherPath.isSubPath(this). */ default boolean isSuperPath(ItemPath otherPath) { return ItemPathComparatorUtil.isSuperPath(this, otherPath); }
/** * Returns true if the segment is the container Id with value of NULL. */ static boolean isNullId(Object o) { return ItemPathSegmentUtil.isNullId(o); }
/** * More strict version of comparison: it requires exact matching of QNames (e.g. x:xyz and xyz are different in this respect). * * @param obj * @return */ @Override public boolean equals(Object obj) { return equals(obj, false, false); }
/** * Returns true if the segment is the Object Reference one ("@"). */ static boolean isObjectReference(Object segment) { return ItemPathSegmentUtil.isObjectReference(segment); }
/** * Returns all segments up to the specified one (including it). */ default ItemPath allUpToIncluding(int i) { return subPath(0, i+1); }
@Override public int hashCode() { final int prime = 31; int result = super.hashCode(); // if we need to compute hash from namespace-normalized name, we would use this one: // (in order for equals to work; if we decide to change equals in such a way later) // result = prime * result + ((name == null) ? 0 : name.getLocalPart().hashCode()); // this version is for "precise" equals result = prime * result + name.hashCode(); return result; }