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.controller.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 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;
18 import javax.annotation.Nullable;
19 import javax.xml.bind.annotation.XmlElement;
20 import java.util.Collection;
22 final class MonitoringSchema {
24 private final Schema schema;
26 public MonitoringSchema(Schema schema) {
30 @XmlElement(name = "identifier")
31 public String getIdentifier() {
32 return schema.getIdentifier();
35 @XmlElement(name = "namespace")
36 public String getNamespace() {
37 return schema.getNamespace().getValue().toString();
40 @XmlElement(name = "location")
41 public Collection<String> getLocation() {
42 return Collections2.transform(schema.getLocation(), new Function<Schema.Location, String>() {
45 public String apply(@Nonnull Schema.Location input) {
46 return input.getEnumeration().toString();
51 @XmlElement(name = "version")
52 public String getVersion() {
53 return schema.getVersion();
56 @XmlElement(name = "format")
57 public String getFormat() {
58 Preconditions.checkState(schema.getFormat() == Yang.class, "Only yang format permitted, but was %s", schema.getFormat());