Merge "Choice and case resolving in JSON output"
[controller.git] / opendaylight / netconf / config-netconf-connector / src / main / java / org / opendaylight / controller / netconf / confignetconfconnector / mapping / attributes / fromxml / AbstractAttributeReadingStrategy.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
9 package org.opendaylight.controller.netconf.confignetconfconnector.mapping.attributes.fromxml;
10
11 import java.util.List;
12
13 import org.opendaylight.controller.config.yangjmxgenerator.attribute.AttributeIfc;
14 import org.opendaylight.controller.netconf.util.xml.XmlElement;
15
16 public abstract class AbstractAttributeReadingStrategy<A extends AttributeIfc> implements AttributeReadingStrategy {
17
18     private final A attributeIfc;
19
20     public AbstractAttributeReadingStrategy(A attributeIfc) {
21         this.attributeIfc = attributeIfc;
22     }
23
24     public A getAttributeIfc() {
25         return attributeIfc;
26     }
27
28     @Override
29     public AttributeConfigElement readElement(List<XmlElement> configNodes) {
30         if (configNodes.size() == 0)
31             return AttributeConfigElement.createNullValue(attributeIfc);
32
33         return readElementHook(configNodes);
34     }
35
36     abstract AttributeConfigElement readElementHook(List<XmlElement> configNodes);
37
38 }