*/
package org.opendaylight.yangtools.yang.parser.builder.impl;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableSet;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
+import java.util.Objects;
import java.util.Set;
-
import org.opendaylight.yangtools.yang.model.api.AugmentationSchema;
import org.opendaylight.yangtools.yang.model.api.GroupingDefinition;
import org.opendaylight.yangtools.yang.model.api.SchemaNode;
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
-import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
import org.opendaylight.yangtools.yang.model.api.UsesNode;
import org.opendaylight.yangtools.yang.parser.builder.api.AugmentationSchemaBuilder;
import org.opendaylight.yangtools.yang.parser.builder.api.Builder;
import org.opendaylight.yangtools.yang.parser.builder.util.AbstractBuilder;
import org.opendaylight.yangtools.yang.parser.util.YangParseException;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.ImmutableSet;
-
+/**
+ * @deprecated Pre-Beryllium implementation, scheduled for removal.
+ */
+@Deprecated
public final class UsesNodeBuilderImpl extends AbstractBuilder implements UsesNodeBuilder {
private UsesNodeImpl instance;
private DataNodeContainerBuilder parentBuilder;
- private final String groupingPathString;
+ private final SchemaPath targetGroupingPath;
private SchemaPath groupingPath;
private GroupingDefinition groupingDefinition;
private GroupingBuilder groupingBuilder;
private final List<SchemaNodeBuilder> refineBuilders = new ArrayList<>();
private final List<RefineBuilder> refines = new ArrayList<>();
- public UsesNodeBuilderImpl(final String moduleName, final int line, final String groupingName) {
+ public UsesNodeBuilderImpl(final String moduleName, final int line, final SchemaPath targetGroupingPath) {
super(moduleName, line);
- this.groupingPathString = groupingName;
+ this.targetGroupingPath = targetGroupingPath;
}
@Override
// AUGMENTATIONS
final Set<AugmentationSchema> augments = new HashSet<>();
for (AugmentationSchemaBuilder builder : augmentationBuilders) {
- augments.add(builder.build());
+ if (!builder.isUnsupportedTarget()) {
+ augments.add(builder.build());
+ }
}
instance.augmentations = ImmutableSet.copyOf(augments);
}
@Override
- public String getGroupingPathAsString() {
- return groupingPathString;
+ public SchemaPath getTargetGroupingPath() {
+ return targetGroupingPath;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
- result = prime * result + ((groupingPathString == null) ? 0 : groupingPathString.hashCode());
- result = prime * result + ((parentBuilder == null) ? 0 : parentBuilder.hashCode());
+ result = prime * result + Objects.hashCode(groupingPath);
+ result = prime * result + Objects.hashCode(parentBuilder);
return result;
}
return false;
}
UsesNodeBuilderImpl other = (UsesNodeBuilderImpl) obj;
- if (groupingPathString == null) {
- if (other.groupingPathString != null) {
+ if (groupingPath == null) {
+ if (other.groupingPath != null) {
return false;
}
- } else if (!groupingPathString.equals(other.groupingPathString)) {
+ } else if (!groupingPath.equals(other.groupingPath)) {
return false;
}
if (parentBuilder == null) {
@Override
public String toString() {
- return "uses '" + groupingPathString + "'";
- }
-
- private static final class UsesNodeImpl implements UsesNode {
- private final SchemaPath groupingPath;
- private ImmutableSet<AugmentationSchema> augmentations;
- private boolean addedByUses;
- private ImmutableMap<SchemaPath, SchemaNode> refines;
- private ImmutableList<UnknownSchemaNode> unknownNodes;
-
- private UsesNodeImpl(final SchemaPath groupingPath) {
- this.groupingPath = groupingPath;
- }
-
- @Override
- public SchemaPath getGroupingPath() {
- return groupingPath;
- }
-
- @Override
- public Set<AugmentationSchema> getAugmentations() {
- return augmentations;
- }
-
- @Override
- public boolean isAugmenting() {
- return false;
- }
-
- @Override
- public boolean isAddedByUses() {
- return addedByUses;
- }
-
- private void setAddedByUses(final boolean addedByUses) {
- this.addedByUses = addedByUses;
- }
-
- @Override
- public Map<SchemaPath, SchemaNode> getRefines() {
- return refines;
- }
-
- @SuppressWarnings("unused")
- public List<UnknownSchemaNode> getUnknownSchemaNodes() {
- return unknownNodes;
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((groupingPath == null) ? 0 : groupingPath.hashCode());
- result = prime * result + ((augmentations == null) ? 0 : augmentations.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(final Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- final UsesNodeImpl other = (UsesNodeImpl) obj;
- if (groupingPath == null) {
- if (other.groupingPath != null) {
- return false;
- }
- } else if (!groupingPath.equals(other.groupingPath)) {
- return false;
- }
- if (augmentations == null) {
- if (other.augmentations != null) {
- return false;
- }
- } else if (!augmentations.equals(other.augmentations)) {
- return false;
- }
- return true;
- }
-
- @Override
- public String toString() {
- StringBuilder sb = new StringBuilder(UsesNodeImpl.class.getSimpleName());
- sb.append("[groupingPath=");
- sb.append(groupingPath);
- sb.append("]");
- return sb.toString();
- }
+ return "uses '" + groupingPath + "'";
}
}