Cleanup some major sonar warning in yang/*
[yangtools.git] / yang / yang-data-impl / src / main / java / org / opendaylight / yangtools / yang / data / impl / schema / nodes / AbstractImmutableDataContainerAttrNode.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 package org.opendaylight.yangtools.yang.data.impl.schema.nodes;
9
10 import java.util.Map;
11
12 import org.opendaylight.yangtools.yang.common.QName;
13 import org.opendaylight.yangtools.yang.data.api.AttributesContainer;
14 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
15 import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild;
16
17 import com.google.common.base.MoreObjects.ToStringHelper;
18
19 // FIXME: are attributes part of hashCode/equals?
20 public abstract class AbstractImmutableDataContainerAttrNode<K extends YangInstanceIdentifier.PathArgument>
21         extends AbstractImmutableDataContainerNode<K>
22     implements AttributesContainer {
23
24     private final Map<QName, String> attributes;
25
26     public AbstractImmutableDataContainerAttrNode(
27             final Map<YangInstanceIdentifier.PathArgument, DataContainerChild<? extends YangInstanceIdentifier.PathArgument, ?>> children,
28             final K nodeIdentifier, final Map<QName, String> attributes) {
29         super(children, nodeIdentifier);
30         this.attributes = attributes;
31     }
32
33     @Override
34     public final Map<QName, String> getAttributes() {
35         return attributes;
36     }
37
38     @Override
39     public final Object getAttributeValue(final QName value) {
40         return attributes.get(value);
41     }
42
43     @Override
44     protected ToStringHelper addToStringAttributes(final ToStringHelper toStringHelper) {
45         return super.addToStringAttributes(toStringHelper).add("attributes", attributes);
46     }
47
48 }