Merge "Fix race conditions between config-manager and persister."
[controller.git] / opendaylight / netconf / config-netconf-connector / src / main / java / org / opendaylight / controller / netconf / confignetconfconnector / mapping / attributes / fromxml / ArrayAttributeReadingStrategy.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 com.google.common.collect.Lists;
12 import org.opendaylight.controller.netconf.util.xml.XmlElement;
13
14 import java.util.List;
15
16 public class ArrayAttributeReadingStrategy extends AbstractAttributeReadingStrategy {
17
18     private final AttributeReadingStrategy innerStrategy;
19
20     /**
21      * @param attributeIfc
22      * @param innerStrategy
23      */
24     public ArrayAttributeReadingStrategy(String nullableDefault, AttributeReadingStrategy innerStrategy) {
25         super(nullableDefault);
26         this.innerStrategy = innerStrategy;
27     }
28
29     @Override
30     AttributeConfigElement readElementHook(List<XmlElement> configNodes) {
31         List<Object> innerList = Lists.newArrayList();
32         for (int i = 0; i < configNodes.size(); i++) {
33             innerList.add(innerStrategy.readElement(Lists.newArrayList(configNodes.get(i))).getValue());
34         }
35         return AttributeConfigElement.create(getNullableDefault(), innerList);
36     }
37
38 }