--- /dev/null
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2021 PANTHEON.tech, s.r.o.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.concepts;
+
+/**
+ * An {@link Identifier} tied to some tree-like structure, similar to how {@link java.nio.file.Path} is tied to a
+ * conceptual file system. In addition to equivalence class implied by Identifier, the hierarchical nature of these
+ * identifiers also introduces a notion of containment: a HierarchicalIdentifier is said to contain another
+ * HierarchicalIdentifier if the former points to an ancestor node of the node pointed to by the latter in the same
+ * instance of the tree-like structure they are defined on. This property is expressed through
+ * {@link #contains(HierarchicalIdentifier)}.
+ */
+public interface HierarchicalIdentifier<T extends HierarchicalIdentifier<T>> extends Identifier, Path<T> {
+ /**
+ * Check if this identifier contains some other identifier. If we take HierarchicalIdentifier to be similar to a
+ * {@link java.nio.file.Path}, this is method is the equivalent of {@code other.startsWith(this)}.
+ *
+ * @param other Other identifier, may not be null
+ * @return True if this identifier contains the other identifier
+ * @throws NullPointerException if {@code other} is null
+ */
+ @Override
+ boolean contains(T other);
+}
* identified by the former contains all elements of the data set represented by later.
*
* @param <P> Path equivalence class
+ * @deprecated This interface does not completely capture the modeling intent. Use {@link HierarchicalIdentifier}
+ * instead.
*/
+@Deprecated(since = "7.0.9", forRemoval = true)
public interface Path<P extends Path<P>> {
/**
* Check if this path contains some other.
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
import org.opendaylight.yangtools.concepts.Builder;
+import org.opendaylight.yangtools.concepts.HierarchicalIdentifier;
import org.opendaylight.yangtools.concepts.Immutable;
-import org.opendaylight.yangtools.concepts.Path;
import org.opendaylight.yangtools.util.HashCodeBuilder;
import org.opendaylight.yangtools.util.ImmutableOffsetMap;
import org.opendaylight.yangtools.util.SingletonSet;
// FIXME: 7.0.0: this concept needs to be moved to yang-common, as parser components need the ability to refer
// to data nodes -- most notably XPath expressions and {@code default} statement arguments need to be able
// to represent these.
-public abstract class YangInstanceIdentifier implements Path<YangInstanceIdentifier>, Immutable, Serializable {
+public abstract class YangInstanceIdentifier implements HierarchicalIdentifier<YangInstanceIdentifier> {
private static final AtomicReferenceFieldUpdater<YangInstanceIdentifier, String> TOSTRINGCACHE_UPDATER =
AtomicReferenceFieldUpdater.newUpdater(YangInstanceIdentifier.class, String.class, "toStringCache");
private static final long serialVersionUID = 4L;