2 * Copyright (c) 2020 PANTHEON.tech, s.r.o. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.yangtools.yang.parser.spi.meta;
10 import static java.util.Objects.requireNonNull;
12 import com.google.common.base.MoreObjects;
13 import java.io.Serial;
14 import org.eclipse.jdt.annotation.NonNullByDefault;
15 import org.opendaylight.yangtools.concepts.Identifier;
18 * {@link ParserNamespace} serves as common superclass for namespaces used during parser operation. Each such namespace,
19 * is a type-captured subclass. This type capture of namespace allows for handy type-safe reading methods such as
20 * {@link NamespaceStmtCtx#namespaceItem(ParserNamespace, Object)} and still allows introduction of new namespaces
21 * without need to change APIs.
23 * @param <K> Identifier type
24 * @param <V> Value type
27 public final class ParserNamespace<K, V> implements Identifier {
29 private static final long serialVersionUID = 1L;
31 private final String name;
33 // FIXME: hide this constructor once we collapse the type hierarchy
34 public ParserNamespace(final String name) {
35 this.name = requireNonNull(name);
39 public String toString() {
40 return MoreObjects.toStringHelper(this).add("name", name).toString();