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
9 package org.opendaylight.controller.netconf.confignetconfconnector.mapping.attributes.fromxml;
11 import org.opendaylight.controller.netconf.api.NetconfDocumentedException;
12 import org.opendaylight.controller.netconf.util.xml.XmlElement;
14 import java.util.List;
16 public abstract class AbstractAttributeReadingStrategy implements AttributeReadingStrategy {
18 private final String nullableDefault;
20 public AbstractAttributeReadingStrategy(String nullableDefault) {
21 this.nullableDefault = nullableDefault;
24 public String getNullableDefault() {
25 return nullableDefault;
29 public AttributeConfigElement readElement(List<XmlElement> configNodes) throws NetconfDocumentedException {
30 if (configNodes.size() == 0){
31 return AttributeConfigElement.createNullValue(postprocessNullableDefault(nullableDefault));
33 return readElementHook(configNodes);
36 abstract AttributeConfigElement readElementHook(List<XmlElement> configNodes) throws NetconfDocumentedException;
38 protected Object postprocessNullableDefault(String nullableDefault) {
39 return nullableDefault;