Revert "Revert "Updated SchemaNodeIdentifier namespace handling.""
[yangtools.git] / yang / yang-parser-impl / src / main / java / org / opendaylight / yangtools / yang / parser / spi / meta / DerivedNamespaceBehaviour.java
1 /*
2  * Copyright (c) 2015 Cisco Systems, Inc. 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.spi.meta;
9
10 import com.google.common.base.Preconditions;
11 import java.util.Map;
12 import org.opendaylight.yangtools.yang.model.api.meta.IdentifierNamespace;
13
14 public abstract class DerivedNamespaceBehaviour<K, V, N extends IdentifierNamespace<K, V>, T extends IdentifierNamespace<?, ?>>
15         extends NamespaceBehaviour<K, V, N> {
16
17     private Class<T> derivedFrom;
18
19     protected DerivedNamespaceBehaviour(Class<N> identifier, Class<T> derivedFrom) {
20         super(identifier);
21         this.derivedFrom = Preconditions.checkNotNull(derivedFrom);
22     }
23
24     public Class<T> getDerivedFrom() {
25         return derivedFrom;
26     }
27
28     @Override
29     public Map<K, V> getAllFrom(NamespaceStorageNode storage) {
30         throw new UnsupportedOperationException("Virtual namespaces does not support provision of all items.");
31     }
32
33     @Override
34     public abstract V getFrom(NamespaceBehaviour.NamespaceStorageNode storage, K key);
35
36     @Override
37     public void addTo(NamespaceStorageNode storage, K key, V value) {
38         // Intentional noop
39     }
40 }