10a66afd1d3d36cf18191efb130811b0b755274b
[yangtools.git] / common / concepts / src / main / java / org / opendaylight / yangtools / concepts / HierarchicalIdentifier.java
1 /*
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  * Copyright (c) 2021 PANTHEON.tech, s.r.o.
4  *
5  * This program and the accompanying materials are made available under the
6  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
7  * and is available at http://www.eclipse.org/legal/epl-v10.html
8  */
9 package org.opendaylight.yangtools.concepts;
10
11 /**
12  * An {@link Identifier} tied to some tree-like structure, similar to how {@link java.nio.file.Path} is tied to a
13  * conceptual file system. In addition to equivalence class implied by Identifier, the hierarchical nature of these
14  * identifiers also introduces a notion of containment: a HierarchicalIdentifier is said to contain another
15  * HierarchicalIdentifier if the former points to an ancestor node of the node pointed to by the latter in the same
16  * instance of the tree-like structure they are defined on. This property is expressed through
17  * {@link #contains(HierarchicalIdentifier)}.
18  */
19 public interface HierarchicalIdentifier<T extends HierarchicalIdentifier<T>> extends Identifier {
20     /**
21      * Check if this identifier contains some other identifier. If we take HierarchicalIdentifier to be similar to a
22      * {@link java.nio.file.Path}, this is method is the equivalent of {@code other.startsWith(this)}.
23      *
24      * @param other Other identifier, may not be null
25      * @return True if this identifier contains the other identifier
26      * @throws NullPointerException if {@code other} is null
27      */
28     boolean contains(T other);
29 }