Populate data/ hierarchy
[yangtools.git] / data / yang-data-util / src / main / java / org / opendaylight / yangtools / yang / data / util / ImmutableNormalizedAnydata.java
1 /*
2  * Copyright (c) 2019 PANTHEON.tech, s.r.o. 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.util;
9
10 import static java.util.Objects.requireNonNull;
11
12 import com.google.common.annotations.Beta;
13 import com.google.common.base.MoreObjects;
14 import com.google.common.base.MoreObjects.ToStringHelper;
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.eclipse.jdt.annotation.Nullable;
17 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedAnydata;
18 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
19 import org.opendaylight.yangtools.yang.model.api.EffectiveStatementInference;
20
21 @Beta
22 @NonNullByDefault
23 public class ImmutableNormalizedAnydata implements NormalizedAnydata {
24     private final EffectiveStatementInference inference;
25     private final NormalizedNode data;
26
27     public ImmutableNormalizedAnydata(final EffectiveStatementInference inference, final NormalizedNode data) {
28         this.inference = requireNonNull(inference);
29         this.data = requireNonNull(data);
30     }
31
32     @Override
33     public final EffectiveStatementInference getInference() {
34         return inference;
35     }
36
37     @Override
38     public final NormalizedNode getData() {
39         return data;
40     }
41
42     @Override
43     public final int hashCode() {
44         return super.hashCode();
45     }
46
47     @Override
48     public final boolean equals(final @Nullable Object obj) {
49         return super.equals(obj);
50     }
51
52     @Override
53     public final String toString() {
54         return addToStringAttributes(MoreObjects.toStringHelper(this)).toString();
55     }
56
57     protected ToStringHelper addToStringAttributes(final ToStringHelper helper) {
58         return helper.add("inference", inference).add("data", data);
59     }
60
61 }