Merge "Migrate NetconfHelloMessage's use of Optional"
[netconf.git] / netconf / netconf-monitoring / src / main / java / org / opendaylight / netconf / monitoring / xml / model / 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.monitoring.xml.model;
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.netconf.monitoring.MonitoringConstants;
17 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.netconf.state.Schemas;
18 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.netconf.state.Sessions;
19
20 @XmlRootElement(name = MonitoringConstants.NETCONF_MONITORING_XML_ROOT_ELEMENT)
21 public final class NetconfState {
22
23     private Schemas schemas;
24     private Sessions sessions;
25
26     public NetconfState(final NetconfMonitoringService monitoringService) {
27         this.sessions = monitoringService.getSessions();
28         this.schemas = monitoringService.getSchemas();
29     }
30
31     public NetconfState() {}
32
33     @XmlElementWrapper(name = "schemas")
34     @XmlElement(name = "schema")
35     public Collection<MonitoringSchema> getSchemas() {
36         return Collections2.transform(schemas.getSchema(), MonitoringSchema::new);
37     }
38
39     @XmlElementWrapper(name = "sessions")
40     @XmlElement(name = "session")
41     public Collection<MonitoringSession> getSessions() {
42         return Collections2.transform(sessions.getSession(), MonitoringSession::new);
43     }
44 }