Merge "Remove dead code in RuntimeMappingModule"
[controller.git] / opendaylight / netconf / config-netconf-connector / src / main / java / org / opendaylight / controller / netconf / confignetconfconnector / mapping / attributes / toxml / SimpleCompositeAttributeWritingStrategy.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.toxml;
10
11 import com.google.common.base.Preconditions;
12 import org.opendaylight.controller.netconf.confignetconfconnector.util.Util;
13 import org.w3c.dom.Document;
14
15 import java.util.Map;
16
17 public class SimpleCompositeAttributeWritingStrategy extends SimpleAttributeWritingStrategy {
18
19     /**
20      * @param document
21      * @param key
22      */
23     public SimpleCompositeAttributeWritingStrategy(Document document, String key) {
24         super(document, key);
25     }
26
27     protected Object preprocess(Object value) {
28         Util.checkType(value, Map.class);
29         Preconditions.checkArgument(((Map)value).size() == 1, "Unexpected number of values in %s, expected 1", value);
30         return ((Map)value).values().iterator().next();
31     }
32
33 }