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 com.google.common.base.Optional;
12 import org.opendaylight.controller.netconf.api.NetconfDocumentedException;
13 import org.opendaylight.controller.netconf.confignetconfconnector.mapping.attributes.resolving.AttributeResolvingStrategy;
15 import javax.management.openmbean.OpenType;
18 * Parsed xml element containing configuration for one attribute of an instance
19 * of some module. Contains default value extracted from yang file.
21 public class AttributeConfigElement {
22 private final Object dafaultValue;
23 private final Object value;
25 private Optional<?> resolvedValue;
26 private Object resolvedDefaultValue;
27 private String jmxName;
29 public AttributeConfigElement(Object dafaultValue, Object value) {
30 this.dafaultValue = dafaultValue;
34 public void setJmxName(String jmxName) {
35 this.jmxName = jmxName;
38 public String getJmxName() {
42 public void resolveValue(AttributeResolvingStrategy<?, ? extends OpenType<?>> attributeResolvingStrategy,
43 String attrName) throws NetconfDocumentedException {
44 resolvedValue = attributeResolvingStrategy.parseAttribute(attrName, value);
45 Optional<?> resolvedDefault = attributeResolvingStrategy.parseAttribute(attrName, dafaultValue);
46 resolvedDefaultValue = resolvedDefault.isPresent() ? resolvedDefault.get() : null;
49 public static AttributeConfigElement create(Object nullableDefault, Object value) {
50 return new AttributeConfigElement(nullableDefault, value);
53 public static AttributeConfigElement createNullValue(Object nullableDefault) {
54 return new AttributeConfigElement(nullableDefault, null);
57 public Object getValue() {
61 public Optional<?> getResolvedValue() {
65 public Object getResolvedDefaultValue() {
66 return resolvedDefaultValue;
70 public String toString() {
71 return "AttributeConfigElement [dafaultValue=" + dafaultValue + ", value=" + value + "]";