Remove unneeded annontation
[yangtools.git] / yang / yang-parser-impl / src / main / java / org / opendaylight / yangtools / yang / parser / builder / impl / UsesNodeImpl.java
1 /*
2  * Copyright (c) 2013-2015 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.parser.builder.impl;
9
10 import com.google.common.collect.ImmutableList;
11 import com.google.common.collect.ImmutableMap;
12 import com.google.common.collect.ImmutableSet;
13 import java.util.List;
14 import java.util.Map;
15 import java.util.Set;
16 import org.opendaylight.yangtools.yang.model.api.AugmentationSchema;
17 import org.opendaylight.yangtools.yang.model.api.SchemaNode;
18 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
19 import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
20 import org.opendaylight.yangtools.yang.model.api.UsesNode;
21
22 final class UsesNodeImpl implements UsesNode {
23     private final SchemaPath groupingPath;
24     ImmutableSet<AugmentationSchema> augmentations;
25     private boolean addedByUses;
26     ImmutableMap<SchemaPath, SchemaNode> refines;
27     ImmutableList<UnknownSchemaNode> unknownNodes;
28
29     UsesNodeImpl(final SchemaPath groupingPath) {
30         this.groupingPath = groupingPath;
31     }
32
33     @Override
34     public SchemaPath getGroupingPath() {
35         return groupingPath;
36     }
37
38     @Override
39     public Set<AugmentationSchema> getAugmentations() {
40         return augmentations;
41     }
42
43     @Override
44     public boolean isAugmenting() {
45         return false;
46     }
47
48     @Override
49     public boolean isAddedByUses() {
50         return addedByUses;
51     }
52
53     void setAddedByUses(final boolean addedByUses) {
54         this.addedByUses = addedByUses;
55     }
56
57     @Override
58     public Map<SchemaPath, SchemaNode> getRefines() {
59         return refines;
60     }
61
62     public List<UnknownSchemaNode> getUnknownSchemaNodes() {
63         return unknownNodes;
64     }
65
66     @Override
67     public int hashCode() {
68         final int prime = 31;
69         int result = 1;
70         result = prime * result + ((groupingPath == null) ? 0 : groupingPath.hashCode());
71         result = prime * result + ((augmentations == null) ? 0 : augmentations.hashCode());
72         return result;
73     }
74
75     @Override
76     public boolean equals(final Object obj) {
77         if (this == obj) {
78             return true;
79         }
80         if (obj == null) {
81             return false;
82         }
83         if (getClass() != obj.getClass()) {
84             return false;
85         }
86         final UsesNodeImpl other = (UsesNodeImpl) obj;
87         if (groupingPath == null) {
88             if (other.groupingPath != null) {
89                 return false;
90             }
91         } else if (!groupingPath.equals(other.groupingPath)) {
92             return false;
93         }
94         if (augmentations == null) {
95             if (other.augmentations != null) {
96                 return false;
97             }
98         } else if (!augmentations.equals(other.augmentations)) {
99             return false;
100         }
101         return true;
102     }
103
104     @Override
105     public String toString() {
106         StringBuilder sb = new StringBuilder(UsesNodeImpl.class.getSimpleName());
107         sb.append("[groupingPath=");
108         sb.append(groupingPath);
109         sb.append("]");
110         return sb.toString();
111     }
112 }