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