Remove opendaylight directory
[netconf.git] / netconf / netconf-monitoring / src / main / java / org / opendaylight / netconf / monitoring / xml / model / MonitoringSchema.java
diff --git a/netconf/netconf-monitoring/src/main/java/org/opendaylight/netconf/monitoring/xml/model/MonitoringSchema.java b/netconf/netconf-monitoring/src/main/java/org/opendaylight/netconf/monitoring/xml/model/MonitoringSchema.java
new file mode 100644 (file)
index 0000000..a629ac3
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.netconf.monitoring.xml.model;
+
+import com.google.common.base.Function;
+import com.google.common.base.Preconditions;
+import com.google.common.collect.Collections2;
+import java.util.Collection;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+import javax.xml.bind.annotation.XmlElement;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.Yang;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.netconf.state.schemas.Schema;
+
+final class MonitoringSchema {
+
+    private final Schema schema;
+
+    public MonitoringSchema(Schema schema) {
+        this.schema = schema;
+    }
+
+    @XmlElement(name = "identifier")
+    public String getIdentifier() {
+        return schema.getIdentifier();
+    }
+
+    @XmlElement(name = "namespace")
+    public String getNamespace() {
+        return schema.getNamespace().getValue().toString();
+    }
+
+    @XmlElement(name = "location")
+    public Collection<String> getLocation() {
+        return Collections2.transform(schema.getLocation(), new Function<Schema.Location, String>() {
+            @Nullable
+            @Override
+            public String apply(@Nonnull Schema.Location input) {
+                return input.getEnumeration().toString();
+            }
+        });
+    }
+
+    @XmlElement(name = "version")
+    public String getVersion() {
+        return schema.getVersion();
+    }
+
+    @XmlElement(name = "format")
+    public String getFormat() {
+        Preconditions.checkState(schema.getFormat() == Yang.class, "Only yang format permitted, but was %s", schema.getFormat());
+        return "yang";
+    }
+}