2 * Copyright (c) 2015, 2017 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.config.facade.xml.mapping.attributes.fromxml;
11 import java.util.List;
12 import org.opendaylight.controller.config.util.xml.DocumentedException;
13 import org.opendaylight.controller.config.util.xml.XmlElement;
15 public abstract class AbstractAttributeReadingStrategy implements AttributeReadingStrategy {
17 private final String nullableDefault;
19 public AbstractAttributeReadingStrategy(final String nullableDefault) {
20 this.nullableDefault = nullableDefault;
23 public String getNullableDefault() {
24 return nullableDefault;
28 public AttributeConfigElement readElement(final List<XmlElement> configNodes) throws DocumentedException {
29 if (configNodes.isEmpty()) {
30 return AttributeConfigElement.createNullValue(postprocessNullableDefault(nullableDefault));
32 return readElementHook(configNodes);
35 abstract AttributeConfigElement readElementHook(List<XmlElement> configNodes) throws DocumentedException;
37 @SuppressWarnings("checkstyle:hiddenField")
38 protected Object postprocessNullableDefault(final String nullableDefault) {
39 return nullableDefault;