Merge "Bug-915: Adding static document generation. Currently the API Explorer can...
[controller.git] / opendaylight / netconf / netconf-monitoring / src / main / java / org / opendaylight / controller / netconf / monitoring / xml / model / MonitoringSchema.java
1 /*
2  * Copyright (c) 2013 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
9 package org.opendaylight.controller.netconf.monitoring.xml.model;
10
11 import com.google.common.base.Function;
12 import com.google.common.base.Preconditions;
13 import com.google.common.collect.Collections2;
14 import java.util.Collection;
15 import javax.annotation.Nonnull;
16 import javax.annotation.Nullable;
17 import javax.xml.bind.annotation.XmlElement;
18 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.Yang;
19 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.netconf.state.schemas.Schema;
20
21 final class MonitoringSchema {
22
23     private final Schema schema;
24
25     public MonitoringSchema(Schema schema) {
26         this.schema = schema;
27     }
28
29     @XmlElement(name = "identifier")
30     public String getIdentifier() {
31         return schema.getIdentifier();
32     }
33
34     @XmlElement(name = "namespace")
35     public String getNamespace() {
36         return schema.getNamespace().getValue().toString();
37     }
38
39     @XmlElement(name = "location")
40     public Collection<String> getLocation() {
41         return Collections2.transform(schema.getLocation(), new Function<Schema.Location, String>() {
42             @Nullable
43             @Override
44             public String apply(@Nonnull Schema.Location input) {
45                 return input.getEnumeration().toString();
46             }
47         });
48     }
49
50     @XmlElement(name = "version")
51     public String getVersion() {
52         return schema.getVersion();
53     }
54
55     @XmlElement(name = "format")
56     public String getFormat() {
57         Preconditions.checkState(schema.getFormat() == Yang.class, "Only yang format permitted, but was %s", schema.getFormat());
58         return "yang";
59     }
60 }