From: Robert Varga Date: Fri, 27 Nov 2020 10:29:19 +0000 (+0100) Subject: Eliminate AbstractEffectiveModule.schemaTreeNamespace X-Git-Tag: v6.0.2~10 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=yangtools.git;a=commitdiff_plain;h=819f07b5ce34c5d608d2dea0eac21b5b98f6e0a5 Eliminate AbstractEffectiveModule.schemaTreeNamespace We already have DefaultWithDataTree.WithSubstatements's indices, hence there is no point in re-doing the same work. Eliminate duplication and defer to our superclass. JIRA: YANGTOOLS-1188 Change-Id: I9fd775be737ef603be7ae2a914dda2c2d87bf8a3 Signed-off-by: Robert Varga (cherry picked from commit d8119ea5b4ead35fc3dfad489e80e49a034226f6) --- diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/AbstractEffectiveModule.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/AbstractEffectiveModule.java index aab5cb9ac3..603673e94e 100644 --- a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/AbstractEffectiveModule.java +++ b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/AbstractEffectiveModule.java @@ -14,12 +14,10 @@ import com.google.common.annotations.Beta; import com.google.common.base.MoreObjects; import com.google.common.collect.Collections2; import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap.Builder; import com.google.common.collect.ImmutableSet; import java.util.Collection; import java.util.LinkedHashSet; -import java.util.Map; import java.util.Optional; import java.util.Set; import org.eclipse.jdt.annotation.NonNull; @@ -43,7 +41,6 @@ import org.opendaylight.yangtools.yang.model.api.TypeDefinition; import org.opendaylight.yangtools.yang.model.api.UsesNode; import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement; import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement; -import org.opendaylight.yangtools.yang.model.api.meta.IdentifierNamespace; import org.opendaylight.yangtools.yang.model.api.stmt.ContactEffectiveStatement; import org.opendaylight.yangtools.yang.model.api.stmt.DataTreeAwareEffectiveStatement; import org.opendaylight.yangtools.yang.model.api.stmt.ImportEffectiveStatement; @@ -51,8 +48,6 @@ import org.opendaylight.yangtools.yang.model.api.stmt.ModuleEffectiveStatement; import org.opendaylight.yangtools.yang.model.api.stmt.OrganizationEffectiveStatement; import org.opendaylight.yangtools.yang.model.api.stmt.PrefixEffectiveStatement; import org.opendaylight.yangtools.yang.model.api.stmt.PrefixStatement; -import org.opendaylight.yangtools.yang.model.api.stmt.SchemaTreeAwareEffectiveStatement; -import org.opendaylight.yangtools.yang.model.api.stmt.SchemaTreeEffectiveStatement; import org.opendaylight.yangtools.yang.model.api.stmt.TypedefEffectiveStatement; import org.opendaylight.yangtools.yang.model.api.stmt.YangVersionEffectiveStatement; import org.opendaylight.yangtools.yang.model.api.stmt.compat.NotificationNodeContainerCompat; @@ -73,23 +68,12 @@ public abstract class AbstractEffectiveModule groupings; private final ImmutableSet uses; private final ImmutableSet> typeDefinitions; - private final ImmutableMap> schemaTreeNamespace; protected AbstractEffectiveModule(final D declared, final StmtContext> ctx, final ImmutableList> substatements, final String prefix) { super(declared, ctx, substatements); - // This check is rather weird, but comes from our desire to lower memory footprint while providing both - // EffectiveStatements and SchemaNode interfaces -- which do not overlap completely where child lookups are - // concerned. This ensures that we have SchemaTree index available for use with child lookups. - final Map> schemaTree = - createSchemaTreeNamespace(ctx.getStatementSourceReference(), effectiveSubstatements()); - schemaTreeNamespace = ImmutableMap.copyOf(schemaTree); - - // Data tree check, not currently used - createDataTreeNamespace(ctx.getStatementSourceReference(), schemaTree.values(), schemaTreeNamespace); - this.prefix = requireNonNull(prefix); final Set mutableGroupings = new LinkedHashSet<>(); @@ -206,8 +190,7 @@ public abstract class AbstractEffectiveModule findDataChildByName(final QName name) { - final SchemaTreeEffectiveStatement child = schemaTreeNamespace.get(requireNonNull(name)); - return child instanceof DataSchemaNode ? Optional.of((DataSchemaNode) child) : Optional.empty(); + return findDataSchemaNode(name); } @Override @@ -220,16 +203,6 @@ public abstract class AbstractEffectiveModule> Optional> getNamespaceContents( - final Class namespace) { - if (SchemaTreeAwareEffectiveStatement.Namespace.class.equals(namespace)) { - return Optional.of((Map) schemaTreeNamespace); - } - return super.getNamespaceContents(namespace); - } - @Override public String toString() { return MoreObjects.toStringHelper(this).omitNullValues()