1 package org.opendaylight.yangtools.yang.data.impl.util;
6 import java.util.concurrent.ConcurrentHashMap;
8 import org.opendaylight.yangtools.yang.common.QName;
9 import org.opendaylight.yangtools.yang.data.api.Node;
11 public abstract class AbstractNodeBuilder<P extends Node<?>, T extends NodeBuilder<P, T>> implements NodeBuilder<P, T> {
13 private final Map<QName, String> attributes;
16 public AbstractNodeBuilder() {
17 this.attributes = new ConcurrentHashMap<>();
20 public AbstractNodeBuilder(QName nodeType, Map<QName, String> attributes) {
22 this.qName = nodeType;
23 this.attributes = new ConcurrentHashMap<>(attributes);
26 public AbstractNodeBuilder(QName nodeType) {
27 this.qName = nodeType;
28 this.attributes = new ConcurrentHashMap<>();
31 @SuppressWarnings("unchecked")
32 protected final T thisInstance() {
37 public final T setQName(QName name) {
39 return thisInstance();
42 public QName getQName() {
47 public final T setAttribute(QName attrName, String attrValue) {
48 attributes.put(attrName, attrValue);
49 return thisInstance();
52 public Map<QName, String> getAttributes() {
57 public T setAttribute(String attrName, String attrValue) {
58 attributes.put(QName.create(qName, attrName), attrValue);
59 return thisInstance();