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
8 package org.opendaylight.netconf.monitoring.xml.model;
10 import com.google.common.base.Function;
11 import com.google.common.collect.Collections2;
12 import java.util.Collection;
13 import javax.annotation.Nullable;
14 import javax.xml.bind.annotation.XmlElement;
15 import javax.xml.bind.annotation.XmlElementWrapper;
16 import javax.xml.bind.annotation.XmlRootElement;
17 import org.opendaylight.netconf.api.monitoring.NetconfMonitoringService;
18 import org.opendaylight.netconf.monitoring.MonitoringConstants;
19 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.netconf.state.Schemas;
20 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.netconf.state.Sessions;
21 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.netconf.state.schemas.Schema;
22 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.netconf.state.sessions.Session;
24 @XmlRootElement(name = MonitoringConstants.NETCONF_MONITORING_XML_ROOT_ELEMENT)
25 public final class NetconfState {
27 private Schemas schemas;
28 private Sessions sessions;
30 public NetconfState(final NetconfMonitoringService monitoringService) {
31 this.sessions = monitoringService.getSessions();
32 this.schemas = monitoringService.getSchemas();
35 public NetconfState() {}
37 @XmlElementWrapper(name="schemas")
38 @XmlElement(name="schema")
39 public Collection<MonitoringSchema> getSchemas() {
40 return Collections2.transform(schemas.getSchema(), new Function<Schema, MonitoringSchema>() {
43 public MonitoringSchema apply(@Nullable final Schema input) {
44 return new MonitoringSchema(input);
49 @XmlElementWrapper(name="sessions")
50 @XmlElement(name="session")
51 public Collection<MonitoringSession> getSessions() {
52 return Collections2.transform(sessions.getSession(), new Function<Session, MonitoringSession>() {
55 public MonitoringSession apply(@Nullable final Session input) {
56 return new MonitoringSession(input);