Bug-915: Adding static document generation.
[controller.git] / opendaylight / netconf / netconf-monitoring / src / main / java / org / opendaylight / controller / 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.controller.netconf.monitoring.xml.model;
9
10 import com.google.common.base.Function;
11 import com.google.common.collect.Collections2;
12 import org.opendaylight.controller.netconf.api.monitoring.NetconfMonitoringService;
13 import org.opendaylight.controller.netconf.monitoring.MonitoringConstants;
14 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.netconf.state.Schemas;
15 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.netconf.state.Sessions;
16 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.netconf.state.schemas.Schema;
17 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.netconf.state.sessions.Session;
18
19 import javax.annotation.Nullable;
20 import javax.xml.bind.annotation.XmlElement;
21 import javax.xml.bind.annotation.XmlElementWrapper;
22 import javax.xml.bind.annotation.XmlRootElement;
23 import java.util.Collection;
24
25 @XmlRootElement(name = MonitoringConstants.NETCONF_MONITORING_XML_ROOT_ELEMENT)
26 public final class NetconfState {
27
28     private Schemas schemas;
29     private Sessions sessions;
30
31     public NetconfState(final NetconfMonitoringService monitoringService) {
32         this.sessions = monitoringService.getSessions();
33         this.schemas = monitoringService.getSchemas();
34     }
35
36     public NetconfState() {}
37
38     @XmlElementWrapper(name="schemas")
39     @XmlElement(name="schema")
40     public Collection<MonitoringSchema> getSchemas() {
41         return Collections2.transform(schemas.getSchema(), new Function<Schema, MonitoringSchema>() {
42             @Nullable
43             @Override
44             public MonitoringSchema apply(@Nullable final Schema input) {
45                 return new MonitoringSchema(input);
46             }
47         });
48     }
49
50     @XmlElementWrapper(name="sessions")
51     @XmlElement(name="session")
52     public Collection<MonitoringSession> getSessions() {
53         return Collections2.transform(sessions.getSession(), new Function<Session, MonitoringSession>() {
54             @Nullable
55             @Override
56             public MonitoringSession apply(@Nullable final Session input) {
57                 return new MonitoringSession(input);
58             }
59         });
60     }
61 }