Add a refcount mechanism for substatements
[yangtools.git] / yang / yang-parser-reactor / src / main / java / org / opendaylight / yangtools / yang / parser / stmt / reactor / SweptNamespace.java
1 /*
2  * Copyright (c) 2020 PANTHEON.tech, s.r.o. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.yangtools.yang.parser.stmt.reactor;
9
10 import static java.util.Objects.requireNonNull;
11
12 import com.google.common.base.VerifyException;
13 import java.util.AbstractMap;
14 import java.util.Set;
15
16 /**
17  * Placeholder namespace map which does not allow access and acts as a sentinel for namespaces which have been
18  * explicitly removed from {@link NamespaceStorageSupport}.
19  */
20 final class SweptNamespace extends AbstractMap<Object, Object> {
21     private final Class<?> name;
22
23     SweptNamespace(final Class<?> name) {
24         this.name = requireNonNull(name);
25     }
26
27     @Override
28     public Set<Entry<Object, Object>> entrySet() {
29         throw new VerifyException("Attempted to access swept namespace " + name);
30     }
31 }