2 * Copyright (c) 2013 Cisco Systems, Inc. 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.data.impl.schema.transform.base;
10 import java.util.List;
14 import com.google.common.collect.Maps;
15 import org.opendaylight.yangtools.yang.common.QName;
16 import org.opendaylight.yangtools.yang.model.api.*;
19 * Proxy for AugmentationSchema. Child node schemas are replaced with actual schemas from parent.
21 public final class AugmentationSchemaProxy implements AugmentationSchema {
22 private final AugmentationSchema delegate;
23 private final Set<DataSchemaNode> realChildSchemas;
24 private final Map<QName, DataSchemaNode> mappedChildSchemas;
26 public AugmentationSchemaProxy(AugmentationSchema augmentSchema, Set<DataSchemaNode> realChildSchemas) {
27 this.delegate = augmentSchema;
28 this.realChildSchemas = realChildSchemas;
30 this.mappedChildSchemas = Maps.newHashMap();
31 for (DataSchemaNode realChildSchema : realChildSchemas) {
32 mappedChildSchemas.put(realChildSchema.getQName(), realChildSchema);
37 public RevisionAwareXPath getWhenCondition() {
38 return delegate.getWhenCondition();
42 public String getDescription() {
43 return delegate.getDescription();
47 public String getReference() {
48 return delegate.getReference();
52 public Status getStatus() {
53 return delegate.getStatus();
57 public SchemaPath getTargetPath() {
58 return delegate.getTargetPath();
62 public List<UnknownSchemaNode> getUnknownSchemaNodes() {
63 return delegate.getUnknownSchemaNodes();
67 public Set<TypeDefinition<?>> getTypeDefinitions() {
68 return delegate.getTypeDefinitions();
72 public Set<DataSchemaNode> getChildNodes() {
73 return realChildSchemas;
77 public Set<GroupingDefinition> getGroupings() {
78 return delegate.getGroupings();
82 public DataSchemaNode getDataChildByName(QName name) {
83 if(mappedChildSchemas.containsKey(name)) {
84 return mappedChildSchemas.get(name);
87 throw new IllegalArgumentException("Unknown child: " + name + " in: " + delegate);
91 public DataSchemaNode getDataChildByName(String name) {
93 throw new UnsupportedOperationException("Unable to retrieve child node by name");
97 public Set<UsesNode> getUses() {
98 return delegate.getUses();