/** * 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 static boolean isSuperPathOrEquivalent(ItemPath path1, ItemPath path2) { ItemPath.CompareResult result = compareComplex(path1, path2); return result == ItemPath.CompareResult.SUPERPATH || result == ItemPath.CompareResult.EQUIVALENT; }
/** * Checks if the paths are equivalent. Resolves some differences in path segment representation, * e.g. NameItemPathSegment vs QName, null vs missing Id path segments. * * Does NOT detect higher-level semantic equivalency like activation[1]/administrativeStatus vs activation/administrativeStatus. * These are treated as not equivalent. */ default boolean equivalent(ItemPath path) { return ItemPathComparatorUtil.equivalent(this, path); }
public static ItemPath remainder(ItemPath main, ItemPath prefix) { ItemPathNormalizingIterator mainIterator = normalizingIterator(main); ItemPathNormalizingIterator prefixIterator = normalizingIterator(prefix); while (prefixIterator.hasNext()) { if (!mainIterator.hasNext()) { throw new IllegalArgumentException("Cannot subtract '"+prefix+"' from path '"+main+ "' because it is not a prefix (subpath): it is a superpath instead."); } Object mainSegment = mainIterator.next(); Object prefixSegment = prefixIterator.next(); if (!segmentsEquivalent(mainSegment, prefixSegment)) { throw new IllegalArgumentException("Cannot subtract segment '"+prefixSegment+"' from path '"+main+ "' because it does not contain corresponding segment; it has '"+mainSegment+"' instead."); } } return ItemPathImpl.createFromIterator(mainIterator); }
/** * 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); }
/** * Check if current path is a subpath (prefix) of the other path or they are equivalent. */ default boolean isSubPathOrEquivalent(ItemPath otherPath) { return ItemPathComparatorUtil.isSubPathOrEquivalent(this, otherPath); }
/** * Check if the other path is a subpath (prefix) of this path or they are equivalent. * The same as otherPath.isSubPathOrEquivalent(this). */ default boolean isSuperPathOrEquivalent(ItemPath path) { return ItemPathComparatorUtil.isSuperPathOrEquivalent(this, path); }
/** * Checks if current path is a strict subpath (prefix) of the other path. */ default boolean isSubPath(ItemPath otherPath) { return ItemPathComparatorUtil.isSubPath(this, otherPath); }
/** * Returns true if the given segments are equivalent. */ static boolean segmentsEquivalent(Object segment1, Object segment2) { return ItemPathComparatorUtil.segmentsEquivalent(segment1, segment2); }
public static ItemPath.CompareResult compareComplex(@Nullable ItemPath path1, @Nullable ItemPath path2) { ItemPathNormalizingIterator iterator1 = normalizingIterator(path1); ItemPathNormalizingIterator iterator2 = normalizingIterator(path2); while (iterator1.hasNext() && iterator2.hasNext()) { Object o1 = iterator1.next(); Object o2 = iterator2.next(); if (!segmentsEquivalent(o1, o2)) { return ItemPath.CompareResult.NO_RELATION; } } if (iterator1.hasNext()) { return ItemPath.CompareResult.SUPERPATH; // "this" is longer than "other" } if (iterator2.hasNext()) { return ItemPath.CompareResult.SUBPATH; // "this" is shorter than "other" } return ItemPath.CompareResult.EQUIVALENT; }
public UniformItemPath remainder(ItemPath prefix) { return new UniformItemPathImpl(ItemPathComparatorUtil.remainder(this, prefix)); }
public static boolean isSubPathOrEquivalent(ItemPath path1, ItemPath path2) { ItemPath.CompareResult result = compareComplex(path1, path2); return result == ItemPath.CompareResult.SUBPATH || result == ItemPath.CompareResult.EQUIVALENT; }
static boolean equivalent(ItemPath path1, ItemPath path2) { return ItemPathComparatorUtil.equivalent(path1, path2); }
public static boolean equivalent(ItemPath path1, ItemPath path2) { return compareComplex(path1, path2) == ItemPath.CompareResult.EQUIVALENT; }
public static boolean isSuperPath(ItemPath path1, ItemPath path2) { return compareComplex(path1, path2) == ItemPath.CompareResult.SUPERPATH; }
public static boolean isSubPath(ItemPath path1, ItemPath path2) { return compareComplex(path1, path2) == ItemPath.CompareResult.SUBPATH; }
/** * Compares two item paths. */ default CompareResult compareComplex(@Nullable ItemPath otherPath) { return ItemPathComparatorUtil.compareComplex(this, otherPath); }