6825f8dca47bb717b7394d38276486d6d9867c5d
[netconf.git] / netconf / tools / netconf-testtool / src / main / java / org / opendaylight / netconf / test / tool / monitoring / NetconfState.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 package org.opendaylight.netconf.test.tool.monitoring;
9
10 import com.google.common.collect.Collections2;
11 import java.util.Collection;
12 import javax.xml.bind.annotation.XmlElement;
13 import javax.xml.bind.annotation.XmlElementWrapper;
14 import javax.xml.bind.annotation.XmlRootElement;
15 import org.opendaylight.netconf.api.monitoring.NetconfMonitoringService;
16 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.netconf.state.Schemas;
17 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.netconf.state.Sessions;
18
19 @XmlRootElement(name = MonitoringConstants.NETCONF_MONITORING_XML_ROOT_ELEMENT)
20 public final class NetconfState {
21
22     private Schemas schemas;
23     private Sessions sessions;
24
25     public NetconfState(final NetconfMonitoringService monitoringService) {
26         this.sessions = monitoringService.getSessions();
27         this.schemas = monitoringService.getSchemas();
28     }
29
30     public NetconfState() {}
31
32     @XmlElementWrapper(name = "schemas")
33     @XmlElement(name = "schema")
34     public Collection<MonitoringSchema> getSchemas() {
35         return Collections2.transform(schemas.getSchema(), MonitoringSchema::new);
36     }
37
38     @XmlElementWrapper(name = "sessions")
39     @XmlElement(name = "session")
40     public Collection<MonitoringSession> getSessions() {
41         return Collections2.transform(sessions.getSession(), MonitoringSession::new);
42     }
43 }