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
9 package org.opendaylight.netconf.monitoring.xml.model;
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;
21 final class MonitoringSchema {
23 private final Schema schema;
25 public MonitoringSchema(Schema schema) {
29 @XmlElement(name = "identifier")
30 public String getIdentifier() {
31 return schema.getIdentifier();
34 @XmlElement(name = "namespace")
35 public String getNamespace() {
36 return schema.getNamespace().getValue().toString();
39 @XmlElement(name = "location")
40 public Collection<String> getLocation() {
41 return Collections2.transform(schema.getLocation(), new Function<Schema.Location, String>() {
44 public String apply(@Nonnull Schema.Location input) {
45 return input.getEnumeration().toString();
50 @XmlElement(name = "version")
51 public String getVersion() {
52 return schema.getVersion();
55 @XmlElement(name = "format")
56 public String getFormat() {
57 Preconditions.checkState(schema.getFormat() == Yang.class, "Only yang format permitted, but was %s", schema.getFormat());