import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.List;
-import java.util.Map;
import java.util.Set;
-import java.util.TreeMap;
import java.util.TreeSet;
import org.opendaylight.yangtools.yang.common.QName;
private final ModuleImpl instance;
private final String name;
+ private final String sourcePath;
private final SchemaPath schemaPath;
private URI namespace;
private String prefix;
private Date revision;
- private final Deque<Builder> actualPath = new LinkedList<Builder>();
- private final Set<TypeAwareBuilder> dirtyNodes = new HashSet<TypeAwareBuilder>();
+ private final boolean submodule;
+ private String belongsTo;
+ private ModuleBuilder parent;
+
+ @Override
+ public ModuleBuilder getParent() {
+ return parent;
+ }
+
+ public void setParent(final ModuleBuilder parent) {
+ this.parent = parent;
+ }
+
+ private final Deque<Builder> actualPath = new LinkedList<>();
+ private final Set<TypeAwareBuilder> dirtyNodes = new HashSet<>();
private final Set<ModuleImport> imports = new HashSet<ModuleImport>();
- private final List<AugmentationSchemaBuilder> addedAugments = new ArrayList<AugmentationSchemaBuilder>();
- private final List<AugmentationSchemaBuilder> allAugments = new ArrayList<AugmentationSchemaBuilder>();
- private final Set<UsesNodeBuilder> addedUsesNodes = new HashSet<UsesNodeBuilder>();
- private final List<UsesNodeBuilder> allUsesNodes = new ArrayList<UsesNodeBuilder>();
- private final Set<RpcDefinitionBuilder> addedRpcs = new HashSet<RpcDefinitionBuilder>();
- private final Set<NotificationBuilder> addedNotifications = new HashSet<NotificationBuilder>();
- private final Set<IdentitySchemaNodeBuilder> addedIdentities = new HashSet<IdentitySchemaNodeBuilder>();
- private final Set<FeatureBuilder> addedFeatures = new HashSet<FeatureBuilder>();
- private final Set<DeviationBuilder> addedDeviations = new HashSet<DeviationBuilder>();
- private final Set<TypeDefinitionBuilder> addedTypedefs = new HashSet<TypeDefinitionBuilder>();
- private final List<ExtensionBuilder> addedExtensions = new ArrayList<ExtensionBuilder>();
+
+ private final Set<AugmentationSchema> augments = new LinkedHashSet<>();
+ private final List<AugmentationSchemaBuilder> augmentBuilders = new ArrayList<>();
+ private final List<AugmentationSchemaBuilder> allAugments = new ArrayList<>();
+
+ private final List<GroupingBuilder> allGroupings = new ArrayList<>();
+
+ private final List<UsesNodeBuilder> allUsesNodes = new ArrayList<>();
+
+ private final Set<RpcDefinition> rpcs = new TreeSet<>(Comparators.SCHEMA_NODE_COMP);
+ private final Set<RpcDefinitionBuilder> addedRpcs = new HashSet<>();
+
+ private final Set<NotificationDefinition> notifications = new TreeSet<>(Comparators.SCHEMA_NODE_COMP);
+ private final Set<NotificationBuilder> addedNotifications = new HashSet<>();
+
+ private final Set<IdentitySchemaNode> identities = new TreeSet<>(Comparators.SCHEMA_NODE_COMP);
+ private final Set<IdentitySchemaNodeBuilder> addedIdentities = new HashSet<>();
+
+ private final Set<FeatureDefinition> features = new TreeSet<>(Comparators.SCHEMA_NODE_COMP);
+ private final Set<FeatureBuilder> addedFeatures = new HashSet<>();
+
+ private final Set<Deviation> deviations = new HashSet<>();
+ private final Set<DeviationBuilder> deviationBuilders = new HashSet<>();
+
+ private final List<ExtensionDefinition> extensions = new ArrayList<>();
+ private final List<ExtensionBuilder> addedExtensions = new ArrayList<>();
+
private final List<UnknownSchemaNodeBuilder> allUnknownNodes = new ArrayList<UnknownSchemaNodeBuilder>();
- public ModuleBuilder(final String name) {
+ private final List<ListSchemaNodeBuilder> allLists = new ArrayList<ListSchemaNodeBuilder>();
+
+ private String source;
+
+ public ModuleBuilder(final String name, final String sourcePath) {
+ this(name, false, sourcePath);
+ }
+
+ public ModuleBuilder(final String name, final boolean submodule, final String sourcePath) {
super(name, 0, null);
this.name = name;
- schemaPath = new SchemaPath(Collections.<QName> emptyList(), true);
- instance = new ModuleImpl(name);
+ this.sourcePath = sourcePath;
+ schemaPath = SchemaPath.create(Collections.<QName> emptyList(), true);
+ this.submodule = submodule;
+ instance = new ModuleImpl(name, sourcePath);
+ actualPath.push(this);
+ }
+
+ public ModuleBuilder(final Module base) {
+ super(base.getName(), 0, null);
+ this.name = base.getName();
+ this.sourcePath = base.getModuleSourcePath();
+ schemaPath = SchemaPath.create(Collections.<QName> emptyList(), true);
+ submodule = false;
+ instance = new ModuleImpl(base.getName(), base.getModuleSourcePath());
+ instance.setYangVersion(base.getYangVersion());
actualPath.push(this);
+ namespace = base.getNamespace();
+ prefix = base.getPrefix();
+ revision = base.getRevision();
+
+ for (DataSchemaNode childNode : base.getChildNodes()) {
+ childNodes.add(childNode);
+ }
+
+ typedefs.addAll(base.getTypeDefinitions());
+ groupings.addAll(base.getGroupings());
+ usesNodes.addAll(base.getUses());
+ augments.addAll(base.getAugmentations());
+ rpcs.addAll(base.getRpcs());
+ notifications.addAll(base.getNotifications());
+
+ for (IdentitySchemaNode identityNode : base.getIdentities()) {
+ addedIdentities.add(new IdentitySchemaNodeBuilder(name, identityNode));
+ }
+
+ features.addAll(base.getFeatures());
+ deviations.addAll(base.getDeviations());
+ extensions.addAll(base.getExtensionSchemaNodes());
+ unknownNodes.addAll(base.getUnknownSchemaNodes());
}
/**
instance.setNamespace(namespace);
// TYPEDEFS
- final Set<TypeDefinition<?>> typedefs = new TreeSet<TypeDefinition<?>>(Comparators.SCHEMA_NODE_COMP);
for (TypeDefinitionBuilder tdb : addedTypedefs) {
typedefs.add(tdb.build());
}
instance.setTypeDefinitions(typedefs);
// CHILD NODES
- final Map<QName, DataSchemaNode> children = new TreeMap<QName, DataSchemaNode>(Comparators.QNAME_COMP);
for (DataSchemaNodeBuilder child : addedChildNodes) {
- children.put(child.getQName(), child.build());
+ childNodes.add(child.build());
}
- instance.setChildNodes(children);
+ instance.addChildNodes(childNodes);
// GROUPINGS
- final Set<GroupingDefinition> groupings = new TreeSet<GroupingDefinition>(Comparators.SCHEMA_NODE_COMP);
for (GroupingBuilder gb : addedGroupings) {
groupings.add(gb.build());
}
instance.setGroupings(groupings);
// USES
- final Set<UsesNode> usesDefinitions = new HashSet<UsesNode>();
for (UsesNodeBuilder unb : addedUsesNodes) {
- usesDefinitions.add(unb.build());
+ usesNodes.add(unb.build());
}
- instance.setUses(usesDefinitions);
+ instance.setUses(usesNodes);
// FEATURES
- final Set<FeatureDefinition> features = new TreeSet<FeatureDefinition>(Comparators.SCHEMA_NODE_COMP);
for (FeatureBuilder fb : addedFeatures) {
features.add(fb.build());
}
instance.setFeatures(features);
// NOTIFICATIONS
- final Set<NotificationDefinition> notifications = new TreeSet<NotificationDefinition>(
- Comparators.SCHEMA_NODE_COMP);
for (NotificationBuilder entry : addedNotifications) {
notifications.add(entry.build());
}
instance.setNotifications(notifications);
// AUGMENTATIONS
- final Set<AugmentationSchema> augmentations = new HashSet<AugmentationSchema>();
- for (AugmentationSchemaBuilder builder : addedAugments) {
- augmentations.add(builder.build());
+ for (AugmentationSchemaBuilder builder : augmentBuilders) {
+ augments.add(builder.build());
}
- instance.setAugmentations(augmentations);
+ instance.setAugmentations(augments);
// RPCs
- final Set<RpcDefinition> rpcs = new TreeSet<RpcDefinition>(Comparators.SCHEMA_NODE_COMP);
for (RpcDefinitionBuilder rpc : addedRpcs) {
rpcs.add(rpc.build());
}
instance.setRpcs(rpcs);
// DEVIATIONS
- final Set<Deviation> deviations = new HashSet<Deviation>();
- for (DeviationBuilder entry : addedDeviations) {
+ for (DeviationBuilder entry : deviationBuilders) {
deviations.add(entry.build());
}
instance.setDeviations(deviations);
// EXTENSIONS
- final List<ExtensionDefinition> extensions = new ArrayList<ExtensionDefinition>();
for (ExtensionBuilder eb : addedExtensions) {
extensions.add(eb.build());
}
instance.setExtensionSchemaNodes(extensions);
// IDENTITIES
- final Set<IdentitySchemaNode> identities = new TreeSet<IdentitySchemaNode>(Comparators.SCHEMA_NODE_COMP);
for (IdentitySchemaNodeBuilder id : addedIdentities) {
identities.add(id.build());
}
instance.setIdentities(identities);
// UNKNOWN NODES
- final List<UnknownSchemaNode> unknownNodes = new ArrayList<UnknownSchemaNode>();
for (UnknownSchemaNodeBuilder unb : addedUnknownNodes) {
unknownNodes.add(unb.build());
}
+ Collections.sort(unknownNodes, Comparators.SCHEMA_NODE_COMP);
instance.setUnknownSchemaNodes(unknownNodes);
+ instance.setSource(source);
+
return instance;
}
- public boolean isAllUsesDataCollected() {
- for (UsesNodeBuilder usesNode : allUsesNodes) {
- if (!usesNode.isDataCollected()) {
- return false;
- }
- }
- return true;
+ public String getModuleSourcePath() {
+ return sourcePath;
}
@Override
- public void setParent(Builder parent) {
+ public void setParent(final Builder parent) {
throw new YangParseException(name, 0, "Can not set parent to module");
}
}
}
- public Builder getActualParent() {
- if (actualPath.size() < 2) {
- return null;
- } else {
- Builder builderChild = actualPath.removeFirst();
- Builder builderParent = actualPath.peekFirst();
- actualPath.addFirst(builderChild);
- return builderParent;
- }
- }
-
public Set<TypeAwareBuilder> getDirtyNodes() {
return dirtyNodes;
}
+ public Set<AugmentationSchema> getAugments() {
+ return augments;
+ }
+
+ public List<AugmentationSchemaBuilder> getAugmentBuilders() {
+ return augmentBuilders;
+ }
+
public List<AugmentationSchemaBuilder> getAllAugments() {
return allAugments;
}
- public Set<IdentitySchemaNodeBuilder> getIdentities() {
+ public Set<IdentitySchemaNode> getIdentities() {
+ return identities;
+ }
+
+ public Set<IdentitySchemaNodeBuilder> getAddedIdentities() {
return addedIdentities;
}
+ public Set<FeatureDefinition> getFeatures() {
+ return features;
+ }
+
+ public Set<FeatureBuilder> getAddedFeatures() {
+ return addedFeatures;
+ }
+
+ public List<GroupingBuilder> getAllGroupings() {
+ return allGroupings;
+ }
+
public List<UsesNodeBuilder> getAllUsesNodes() {
return allUsesNodes;
}
- public Set<DeviationBuilder> getDeviations() {
- return addedDeviations;
+ public Set<Deviation> getDeviations() {
+ return deviations;
+ }
+
+ public Set<DeviationBuilder> getDeviationBuilders() {
+ return deviationBuilders;
+ }
+
+ public List<ExtensionDefinition> getExtensions() {
+ return extensions;
}
- public List<ExtensionBuilder> getExtensions() {
+ public List<ExtensionBuilder> getAddedExtensions() {
return addedExtensions;
}
return allUnknownNodes;
}
+ public List<ListSchemaNodeBuilder> getAllLists() {
+ return allLists;
+ }
+
public String getName() {
return name;
}
return revision;
}
+ public boolean isSubmodule() {
+ return submodule;
+ }
+
+ public String getBelongsTo() {
+ return belongsTo;
+ }
+
+ public void setBelongsTo(final String belongsTo) {
+ this.belongsTo = belongsTo;
+ }
+
public void markActualNodeDirty() {
final TypeAwareBuilder nodeBuilder = (TypeAwareBuilder) getActualNode();
dirtyNodes.add(nodeBuilder);
return imports;
}
- public ExtensionBuilder addExtension(final QName qname, final int line) {
+ public ExtensionBuilder addExtension(final QName qname, final int line, final SchemaPath path) {
+ Builder parent = getActualNode();
+ if (!(parent.equals(this))) {
+ throw new YangParseException(name, line, "extension can be defined only in module or submodule");
+ }
+
final String extName = qname.getLocalName();
for (ExtensionBuilder addedExtension : addedExtensions) {
if (addedExtension.getQName().getLocalName().equals(extName)) {
raiseYangParserException("extension", "node", extName, line, addedExtension.getLine());
}
}
- final ExtensionBuilder builder = new ExtensionBuilder(name, line, qname);
+ final ExtensionBuilder builder = new ExtensionBuilder(name, line, qname, path);
+ builder.setParent(parent);
addedExtensions.add(builder);
return builder;
}
Builder parent = getActualNode();
builder.setParent(parent);
addChildToParent(parent, builder, qname.getLocalName());
+ allLists.add(builder);
return builder;
}
return builder;
}
- public GroupingBuilder addGrouping(final int line, final QName qname) {
- final GroupingBuilder builder = new GroupingBuilderImpl(name, line, qname);
+ public GroupingBuilder addGrouping(final int line, final QName qname, final SchemaPath path) {
+ final GroupingBuilder builder = new GroupingBuilderImpl(name, line, qname, path);
Builder parent = getActualNode();
builder.setParent(parent);
}
}
+ allGroupings.add(builder);
return builder;
}
- public AugmentationSchemaBuilder addAugment(final int line, final String augmentTargetStr) {
- final AugmentationSchemaBuilder builder = new AugmentationSchemaBuilderImpl(name, line, augmentTargetStr);
+ public AugmentationSchemaBuilder addAugment(final int line, final String augmentTargetStr, final int order) {
+ final AugmentationSchemaBuilder builder = new AugmentationSchemaBuilderImpl(name, line, augmentTargetStr, order);
Builder parent = getActualNode();
builder.setParent(parent);
if (parent.equals(this)) {
// augment can be declared only under 'module' ...
- addedAugments.add(builder);
+ if (!(augmentTargetStr.startsWith("/"))) {
+ throw new YangParseException(
+ name,
+ line,
+ "If the 'augment' statement is on the top level in a module, the absolute form of a schema node identifier MUST be used.");
+ }
+ augmentBuilders.add(builder);
} else {
// ... or 'uses' statement
if (parent instanceof UsesNodeBuilder) {
}
@Override
- public Set<UsesNodeBuilder> getUsesNodes() {
- return addedUsesNodes;
- }
-
- @Override
- public void addUsesNode(UsesNodeBuilder usesBuilder) {
+ public void addUsesNode(final UsesNodeBuilder usesBuilder) {
addedUsesNodes.add(usesBuilder);
allUsesNodes.add(usesBuilder);
}
}
((DataNodeContainerBuilder) parent).addUsesNode(usesBuilder);
}
- if(parent instanceof AugmentationSchemaBuilder) {
+ if (parent instanceof AugmentationSchemaBuilder) {
usesBuilder.setAugmenting(true);
- usesBuilder.setParentAugment((AugmentationSchemaBuilder)parent);
}
allUsesNodes.add(usesBuilder);
refine.setParent(parent);
}
- public RpcDefinitionBuilder addRpc(final int line, final QName qname) {
+ public RpcDefinitionBuilder addRpc(final int line, final QName qname, final SchemaPath path) {
Builder parent = getActualNode();
if (!(parent.equals(this))) {
throw new YangParseException(name, line, "rpc can be defined only in module or submodule");
}
- final RpcDefinitionBuilder rpcBuilder = new RpcDefinitionBuilder(name, line, qname);
+ final RpcDefinitionBuilder rpcBuilder = new RpcDefinitionBuilder(name, line, qname, path);
rpcBuilder.setParent(parent);
String rpcName = qname.getLocalName();
return outputBuilder;
}
- public NotificationBuilder addNotification(final int line, final QName qname) {
+ public void addNotification(final NotificationDefinition notification) {
+ notifications.add(notification);
+ }
+
+ public NotificationBuilder addNotification(final int line, final QName qname, final SchemaPath path) {
final Builder parent = getActualNode();
if (!(parent.equals(this))) {
throw new YangParseException(name, line, "notification can be defined only in module or submodule");
}
}
- final NotificationBuilder builder = new NotificationBuilder(name, line, qname);
+ final NotificationBuilder builder = new NotificationBuilder(name, line, qname, path);
builder.setParent(parent);
addedNotifications.add(builder);
return builder;
}
- public FeatureBuilder addFeature(final int line, final QName qname) {
+ public FeatureBuilder addFeature(final int line, final QName qname, final SchemaPath path) {
Builder parent = getActualNode();
if (!(parent.equals(this))) {
throw new YangParseException(name, line, "feature can be defined only in module or submodule");
}
- final FeatureBuilder builder = new FeatureBuilder(name, line, qname);
+ final FeatureBuilder builder = new FeatureBuilder(name, line, qname, path);
builder.setParent(parent);
String featureName = qname.getLocalName();
return builder;
}
- public ChoiceBuilder addChoice(final int line, final QName qname) {
- final ChoiceBuilder builder = new ChoiceBuilder(name, line, qname);
+ public ChoiceBuilder addChoice(final int line, final QName qname, final SchemaPath path) {
+ final ChoiceBuilder builder = new ChoiceBuilder(name, line, qname, path);
Builder parent = getActualNode();
builder.setParent(parent);
return builder;
}
- public ChoiceCaseBuilder addCase(final int line, final QName qname) {
+ public ChoiceCaseBuilder addCase(final int line, final QName qname, final SchemaPath path) {
Builder parent = getActualNode();
if (parent == null || parent.equals(this)) {
throw new YangParseException(name, line, "'case' parent not found");
}
- final ChoiceCaseBuilder builder = new ChoiceCaseBuilder(name, line, qname);
+ final ChoiceCaseBuilder builder = new ChoiceCaseBuilder(name, line, qname, path);
builder.setParent(parent);
if (parent instanceof ChoiceBuilder) {
}
@Override
- public void addTypedef(TypeDefinitionBuilder typedefBuilder) {
+ public void addTypedef(final TypeDefinitionBuilder typedefBuilder) {
String nodeName = typedefBuilder.getQName().getLocalName();
for (TypeDefinitionBuilder tdb : addedTypedefs) {
if (tdb.getQName().getLocalName().equals(nodeName)) {
addedTypedefs.add(typedefBuilder);
}
- public TypeDefinitionBuilderImpl addTypedef(final int line, final QName qname) {
- final TypeDefinitionBuilderImpl builder = new TypeDefinitionBuilderImpl(name, line, qname);
+ public TypeDefinitionBuilderImpl addTypedef(final int line, final QName qname, final SchemaPath path) {
+ final TypeDefinitionBuilderImpl builder = new TypeDefinitionBuilderImpl(name, line, qname, path);
Builder parent = getActualNode();
builder.setParent(parent);
final DeviationBuilder builder = new DeviationBuilder(name, line, targetPath);
builder.setParent(parent);
- addedDeviations.add(builder);
+ deviationBuilders.add(builder);
return builder;
}
- public IdentitySchemaNodeBuilder addIdentity(final QName qname, final int line) {
+ public IdentitySchemaNodeBuilder addIdentity(final QName qname, final int line, final SchemaPath path) {
Builder parent = getActualNode();
if (!(parent.equals(this))) {
throw new YangParseException(name, line, "identity can be defined only in module or submodule");
}
}
- final IdentitySchemaNodeBuilder builder = new IdentitySchemaNodeBuilder(name, line, qname);
+ final IdentitySchemaNodeBuilder builder = new IdentitySchemaNodeBuilder(name, line, qname, path);
builder.setParent(parent);
addedIdentities.add(builder);
return builder;
allUnknownNodes.add(builder);
}
- public UnknownSchemaNodeBuilder addUnknownSchemaNode(final int line, final QName qname) {
+ public UnknownSchemaNodeBuilder addUnknownSchemaNode(final int line, final QName qname, final SchemaPath path) {
final Builder parent = getActualNode();
- final UnknownSchemaNodeBuilder builder = new UnknownSchemaNodeBuilder(name, line, qname);
+ final UnknownSchemaNodeBuilder builder = new UnknownSchemaNodeBuilder(name, line, qname, path);
builder.setParent(parent);
allUnknownNodes.add(builder);
return builder;
}
- public Set<RpcDefinitionBuilder> getRpcs() {
+ public Set<RpcDefinition> getRpcs() {
+ return rpcs;
+ }
+
+ public Set<RpcDefinitionBuilder> getAddedRpcs() {
return addedRpcs;
}
- public Set<NotificationBuilder> getNotifications() {
+ public Set<NotificationDefinition> getNotifications() {
+ return notifications;
+ }
+
+ public Set<NotificationBuilder> getAddedNotifications() {
return addedNotifications;
}
return "module " + name;
}
- private final class ModuleImpl implements Module {
+ public void setSource(final String source) {
+ this.source = source;
+ }
+
+ public static final class ModuleImpl implements Module {
private URI namespace;
private final String name;
+ private final String sourcePath;
private Date revision;
private String prefix;
private String yangVersion;
private String reference;
private String organization;
private String contact;
- private Set<ModuleImport> imports = Collections.emptySet();
- private Set<FeatureDefinition> features = Collections.emptySet();
- private Set<TypeDefinition<?>> typeDefinitions = Collections.emptySet();
- private Set<NotificationDefinition> notifications = Collections.emptySet();
- private Set<AugmentationSchema> augmentations = Collections.emptySet();
- private Set<RpcDefinition> rpcs = Collections.emptySet();
- private Set<Deviation> deviations = Collections.emptySet();
- private Map<QName, DataSchemaNode> childNodes = Collections.emptyMap();
- private Set<GroupingDefinition> groupings = Collections.emptySet();
- private Set<UsesNode> uses = Collections.emptySet();
- private List<ExtensionDefinition> extensionNodes = Collections.emptyList();
- private Set<IdentitySchemaNode> identities = Collections.emptySet();
- private List<UnknownSchemaNode> unknownNodes = Collections.emptyList();
-
- private ModuleImpl(String name) {
+ private final Set<ModuleImport> imports = new HashSet<>();
+ private final Set<FeatureDefinition> features = new TreeSet<>(Comparators.SCHEMA_NODE_COMP);
+ private final Set<TypeDefinition<?>> typeDefinitions = new TreeSet<>(Comparators.SCHEMA_NODE_COMP);
+ private final Set<NotificationDefinition> notifications = new TreeSet<>(Comparators.SCHEMA_NODE_COMP);
+ private final Set<AugmentationSchema> augmentations = new HashSet<>();
+ private final Set<RpcDefinition> rpcs = new TreeSet<>(Comparators.SCHEMA_NODE_COMP);
+ private final Set<Deviation> deviations = new HashSet<>();
+ private final Set<DataSchemaNode> childNodes = new TreeSet<>(Comparators.SCHEMA_NODE_COMP);
+ private final Set<GroupingDefinition> groupings = new TreeSet<>(Comparators.SCHEMA_NODE_COMP);
+ private final Set<UsesNode> uses = new HashSet<>();
+ private final List<ExtensionDefinition> extensionNodes = new ArrayList<>();
+ private final Set<IdentitySchemaNode> identities = new TreeSet<>(Comparators.SCHEMA_NODE_COMP);
+ private final List<UnknownSchemaNode> unknownNodes = new ArrayList<>();
+ private String source;
+
+ private ModuleImpl(final String name, final String sourcePath) {
this.name = name;
+ this.sourcePath = sourcePath;
+ }
+
+ @Override
+ public String getModuleSourcePath() {
+ return sourcePath;
}
@Override
return namespace;
}
- private void setNamespace(URI namespace) {
+ private void setNamespace(final URI namespace) {
this.namespace = namespace;
}
return revision;
}
- private void setRevision(Date revision) {
+ private void setRevision(final Date revision) {
this.revision = revision;
}
return prefix;
}
- private void setPrefix(String prefix) {
+ private void setPrefix(final String prefix) {
this.prefix = prefix;
}
return yangVersion;
}
- private void setYangVersion(String yangVersion) {
+ private void setYangVersion(final String yangVersion) {
this.yangVersion = yangVersion;
}
return description;
}
- private void setDescription(String description) {
+ private void setDescription(final String description) {
this.description = description;
}
return reference;
}
- private void setReference(String reference) {
+ private void setReference(final String reference) {
this.reference = reference;
}
return organization;
}
- private void setOrganization(String organization) {
+ private void setOrganization(final String organization) {
this.organization = organization;
}
return contact;
}
- private void setContact(String contact) {
+ private void setContact(final String contact) {
this.contact = contact;
}
return imports;
}
- private void setImports(Set<ModuleImport> imports) {
+ private void setImports(final Set<ModuleImport> imports) {
if (imports != null) {
- this.imports = imports;
+ this.imports.addAll(imports);
}
}
return features;
}
- private void setFeatures(Set<FeatureDefinition> features) {
+ private void setFeatures(final Set<FeatureDefinition> features) {
if (features != null) {
- this.features = features;
+ this.features.addAll(features);
}
}
return typeDefinitions;
}
- private void setTypeDefinitions(Set<TypeDefinition<?>> typeDefinitions) {
+ private void setTypeDefinitions(final Set<TypeDefinition<?>> typeDefinitions) {
if (typeDefinitions != null) {
- this.typeDefinitions = typeDefinitions;
+ this.typeDefinitions.addAll(typeDefinitions);
}
}
return notifications;
}
- private void setNotifications(Set<NotificationDefinition> notifications) {
+ private void setNotifications(final Set<NotificationDefinition> notifications) {
if (notifications != null) {
- this.notifications = notifications;
+ this.notifications.addAll(notifications);
}
}
return augmentations;
}
- private void setAugmentations(Set<AugmentationSchema> augmentations) {
+ private void setAugmentations(final Set<AugmentationSchema> augmentations) {
if (augmentations != null) {
- this.augmentations = augmentations;
+ this.augmentations.addAll(augmentations);
}
}
return rpcs;
}
- private void setRpcs(Set<RpcDefinition> rpcs) {
+ private void setRpcs(final Set<RpcDefinition> rpcs) {
if (rpcs != null) {
- this.rpcs = rpcs;
+ this.rpcs.addAll(rpcs);
}
}
return deviations;
}
- private void setDeviations(Set<Deviation> deviations) {
+ private void setDeviations(final Set<Deviation> deviations) {
if (deviations != null) {
- this.deviations = deviations;
+ this.deviations.addAll(deviations);
}
}
@Override
public Set<DataSchemaNode> getChildNodes() {
- return new LinkedHashSet<DataSchemaNode>(childNodes.values());
+ return Collections.unmodifiableSet(childNodes);
}
- private void setChildNodes(Map<QName, DataSchemaNode> childNodes) {
+ private void addChildNodes(final Set<DataSchemaNode> childNodes) {
if (childNodes != null) {
- this.childNodes = childNodes;
+ this.childNodes.addAll(childNodes);
}
}
return groupings;
}
- private void setGroupings(Set<GroupingDefinition> groupings) {
+ private void setGroupings(final Set<GroupingDefinition> groupings) {
if (groupings != null) {
- this.groupings = groupings;
+ this.groupings.addAll(groupings);
}
}
return uses;
}
- private void setUses(Set<UsesNode> uses) {
+ private void setUses(final Set<UsesNode> uses) {
if (uses != null) {
- this.uses = uses;
+ this.uses.addAll(uses);
}
}
@Override
public List<ExtensionDefinition> getExtensionSchemaNodes() {
+ Collections.sort(extensionNodes, Comparators.SCHEMA_NODE_COMP);
return extensionNodes;
}
private void setExtensionSchemaNodes(final List<ExtensionDefinition> extensionNodes) {
if (extensionNodes != null) {
- this.extensionNodes = extensionNodes;
+ this.extensionNodes.addAll(extensionNodes);
}
}
private void setIdentities(final Set<IdentitySchemaNode> identities) {
if (identities != null) {
- this.identities = identities;
+ this.identities.addAll(identities);
}
}
private void setUnknownSchemaNodes(final List<UnknownSchemaNode> unknownNodes) {
if (unknownNodes != null) {
- this.unknownNodes = unknownNodes;
+ this.unknownNodes.addAll(unknownNodes);
}
}
@Override
- public DataSchemaNode getDataChildByName(QName name) {
- return childNodes.get(name);
+ public DataSchemaNode getDataChildByName(final QName name) {
+ return getChildNode(childNodes, name);
}
@Override
- public DataSchemaNode getDataChildByName(String name) {
- DataSchemaNode result = null;
- for (Map.Entry<QName, DataSchemaNode> entry : childNodes.entrySet()) {
- if (entry.getKey().getLocalName().equals(name)) {
- result = entry.getValue();
- break;
- }
- }
- return result;
+ public DataSchemaNode getDataChildByName(final String name) {
+ return getChildNode(childNodes, name);
+ }
+
+ void setSource(final String source){
+ this.source = source;
+ }
+
+ public String getSource() {
+ return source;
}
@Override
result = prime * result + ((namespace == null) ? 0 : namespace.hashCode());
result = prime * result + ((name == null) ? 0 : name.hashCode());
result = prime * result + ((revision == null) ? 0 : revision.hashCode());
- result = prime * result + ((prefix == null) ? 0 : prefix.hashCode());
result = prime * result + ((yangVersion == null) ? 0 : yangVersion.hashCode());
return result;
}
@Override
- public boolean equals(Object obj) {
+ public boolean equals(final Object obj) {
if (this == obj) {
return true;
}
} else if (!revision.equals(other.revision)) {
return false;
}
- if (prefix == null) {
- if (other.prefix != null) {
- return false;
- }
- } else if (!prefix.equals(other.prefix)) {
- return false;
- }
if (yangVersion == null) {
if (other.yangVersion != null) {
return false;
}
@Override
- public boolean equals(Object obj) {
+ public boolean equals(final Object obj) {
if (this == obj) {
return true;
}
return true;
}
+
}