Merge "Bug 1025: Fixed incorrect revision in sal-remote-augment, which caused log...
[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 javax.annotation.Nonnull;
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 import javax.annotation.Nullable;
19 import javax.xml.bind.annotation.XmlElement;
20 import java.util.Collection;
21
22 final class MonitoringSchema {
23
24     private final Schema schema;
25
26     public MonitoringSchema(Schema schema) {
27         this.schema = schema;
28     }
29
30     @XmlElement(name = "identifier")
31     public String getIdentifier() {
32         return schema.getIdentifier();
33     }
34
35     @XmlElement(name = "namespace")
36     public String getNamespace() {
37         return schema.getNamespace().getValue().toString();
38     }
39
40     @XmlElement(name = "location")
41     public Collection<String> getLocation() {
42         return Collections2.transform(schema.getLocation(), new Function<Schema.Location, String>() {
43             @Nullable
44             @Override
45             public String apply(@Nonnull Schema.Location input) {
46                 return input.getEnumeration().toString();
47             }
48         });
49     }
50
51     @XmlElement(name = "version")
52     public String getVersion() {
53         return schema.getVersion();
54     }
55
56     @XmlElement(name = "format")
57     public String getFormat() {
58         Preconditions.checkState(schema.getFormat() == Yang.class, "Only yang format permitted, but was %s", schema.getFormat());
59         return "yang";
60     }
61 }