32ef6ae3c98f9f143a434956fa5c8558419a38be
[netconf.git] / netconf / tools / netconf-testtool / src / main / java / org / opendaylight / netconf / test / tool / monitoring / 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.netconf.test.tool.monitoring;
10
11 import com.google.common.base.Preconditions;
12 import com.google.common.collect.Collections2;
13 import java.util.Collection;
14 import javax.xml.bind.annotation.XmlElement;
15 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.Yang;
16 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.netconf.state.schemas.Schema;
17
18 final class MonitoringSchema {
19
20     private final Schema schema;
21
22     MonitoringSchema(final Schema schema) {
23         this.schema = schema;
24     }
25
26     @XmlElement(name = "identifier")
27     public String getIdentifier() {
28         return schema.getIdentifier();
29     }
30
31     @XmlElement(name = "namespace")
32     public String getNamespace() {
33         return schema.getNamespace().getValue();
34     }
35
36     @XmlElement(name = "location")
37     public Collection<String> getLocation() {
38         return Collections2.transform(schema.getLocation(), input -> input.getEnumeration().toString());
39     }
40
41     @XmlElement(name = "version")
42     public String getVersion() {
43         return schema.getVersion();
44     }
45
46     @XmlElement(name = "format")
47     public String getFormat() {
48         Preconditions.checkState(schema.getFormat() == Yang.class, "Only yang format permitted, but was %s",
49                 schema.getFormat());
50         return "yang";
51     }
52 }