X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=yang%2Fyang-parser-reactor%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fyangtools%2Fyang%2Fparser%2Fstmt%2Freactor%2FReactorStmtCtx.java;h=da11198357174a1a0bda4652904feeafdd4babb5;hb=b58489321bc04d8c5ebca56bef8ecce3b4e964e2;hp=606b3c218035e9b44052db61fbc84a7e06609790;hpb=817686488c9ca877b5a1c778f5884c7491ff0234;p=yangtools.git diff --git a/yang/yang-parser-reactor/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/ReactorStmtCtx.java b/yang/yang-parser-reactor/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/ReactorStmtCtx.java index 606b3c2180..da11198357 100644 --- a/yang/yang-parser-reactor/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/ReactorStmtCtx.java +++ b/yang/yang-parser-reactor/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/ReactorStmtCtx.java @@ -9,7 +9,6 @@ package org.opendaylight.yangtools.yang.parser.stmt.reactor; import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Verify.verify; -import static com.google.common.base.Verify.verifyNotNull; import com.google.common.base.MoreObjects; import com.google.common.base.MoreObjects.ToStringHelper; @@ -35,7 +34,6 @@ import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier; import org.opendaylight.yangtools.yang.model.api.stmt.UsesStatement; import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier; import org.opendaylight.yangtools.yang.parser.spi.meta.CopyType; -import org.opendaylight.yangtools.yang.parser.spi.meta.EffectiveStatementState; import org.opendaylight.yangtools.yang.parser.spi.meta.EffectiveStmtCtx.Current; import org.opendaylight.yangtools.yang.parser.spi.meta.InferenceException; import org.opendaylight.yangtools.yang.parser.spi.meta.ModelActionBuilder; @@ -120,7 +118,7 @@ abstract class ReactorStmtCtx, E extends Effec * {@link #buildEffective()} instance. If this context is reused, it can be inflated to {@link EffectiveInstances} * and also act as a common instance reuse site. */ - private @Nullable Object effectiveInstance; + private @Nullable E effectiveInstance; // Master flag controlling whether this context can yield an effective statement // FIXME: investigate the mechanics that are being supported by this, as it would be beneficial if we can get rid @@ -265,16 +263,15 @@ abstract class ReactorStmtCtx, E extends Effec @Override public final > @NonNull Optional findSubstatementArgument( final @NonNull Class type) { - final Object existing = effectiveInstance; - return existing != null ? EffectiveInstances.local(existing).findFirstEffectiveSubstatementArgument(type) + final E existing = effectiveInstance; + return existing != null ? existing.findFirstEffectiveSubstatementArgument(type) : findSubstatementArgumentImpl(type); } @Override public final boolean hasSubstatement(final @NonNull Class> type) { - final Object existing = effectiveInstance; - return existing != null ? EffectiveInstances.local(existing).findFirstEffectiveSubstatement(type).isPresent() - : hasSubstatementImpl(type); + final E existing = effectiveInstance; + return existing != null ? existing.findFirstEffectiveSubstatement(type).isPresent() : hasSubstatementImpl(type); } // Visible due to InferredStatementContext's override. At this point we do not have an effective instance available. @@ -381,8 +378,8 @@ abstract class ReactorStmtCtx, E extends Effec @Override public final E buildEffective() { - final Object existing; - return (existing = effectiveInstance) != null ? EffectiveInstances.local(existing) : loadEffective(); + final E existing; + return (existing = effectiveInstance) != null ? existing : loadEffective(); } private @NonNull E loadEffective() { @@ -404,31 +401,6 @@ abstract class ReactorStmtCtx, E extends Effec abstract @NonNull E createEffective(); - - /** - * Attach an effective copy of this statement. This essentially acts as a map, where we make a few assumptions: - *
    - *
  • {@code copy} and {@code this} statement share {@link #getOriginalCtx()} if it exists
  • - *
  • {@code copy} did not modify any statements relative to {@code this}
  • - *
- * - * - * @param state effective statement state, acting as a lookup key - * @param copy New copy to append - * @return {@code copy} or a previously-created instances with the same {@code state} - */ - @SuppressWarnings("unchecked") - final @NonNull E attachCopy(final @NonNull EffectiveStatementState state, final @NonNull E copy) { - final Object effective = verifyNotNull(effectiveInstance, "Attaching copy to a unbuilt %s", this); - final EffectiveInstances instances; - if (effective instanceof EffectiveInstances) { - instances = (EffectiveInstances) effective; - } else { - effectiveInstance = instances = new EffectiveInstances<>((E) effective); - } - return instances.attachCopy(state, copy); - } - /** * Walk this statement's copy history and return the statement closest to original which has not had its effective * statements modified. This statement and returned substatement logically have the same set of substatements, hence @@ -637,9 +609,7 @@ abstract class ReactorStmtCtx, E extends Effec @Override public final QName argumentAsTypeQName() { - final Object argument = argument(); - verify(argument instanceof String, "Unexpected argument %s", argument); - return interpretAsQName((String) argument); + return interpretAsQName(getRawArgument()); } @Override