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 javax.management.openmbean.OpenType;
13 import org.opendaylight.controller.config.yangjmxgenerator.attribute.AttributeIfc;
14 import org.opendaylight.controller.netconf.confignetconfconnector.mapping.attributes.resolving.AttributeResolvingStrategy;
16 import com.google.common.base.Optional;
19 * Parsed xml element containing configuration for one attribute of an instance
20 * of some module. Contains default value extracted from yang file.
22 public class AttributeConfigElement {
23 private final Object dafaultValue;
24 private final Object value;
26 private Optional<?> resolvedValue;
27 private Object resolvedDefaultValue;
28 private String jmxName;
30 public AttributeConfigElement(Object dafaultValue, Object value) {
31 this.dafaultValue = dafaultValue;
35 public void setJmxName(String jmxName) {
36 this.jmxName = jmxName;
39 public String getJmxName() {
43 public void resolveValue(AttributeResolvingStrategy<?, ? extends OpenType<?>> attributeResolvingStrategy,
45 resolvedValue = attributeResolvingStrategy.parseAttribute(attrName, value);
46 Optional<?> resolvedDefault = attributeResolvingStrategy.parseAttribute(attrName, dafaultValue);
47 resolvedDefaultValue = resolvedDefault.isPresent() ? resolvedDefault.get() : null;
51 public static AttributeConfigElement create(AttributeIfc attributeIfc, Object value) {
52 return new AttributeConfigElement(attributeIfc.getNullableDefault(), value);
55 public static AttributeConfigElement createNullValue(AttributeIfc attributeIfc) {
56 return new AttributeConfigElement(attributeIfc.getNullableDefault(), null);
59 public Object getValue() {
63 public Optional<?> getResolvedValue() {
67 public Object getResolvedDefaultValue() {
68 return resolvedDefaultValue;
72 public String toString() {
73 return "AttributeConfigElement [dafaultValue=" + dafaultValue + ", value=" + value + "]";