We have the same facility in StatementContextBase.getParentContext(),
hence we can directly reuse it.
JIRA: YANGTOOLS-1184
Change-Id: Ie0d13fc86e50764a5e27ed0cb3d1d5731ddf6116
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
import com.google.common.base.VerifyException;
import java.util.Collection;
import com.google.common.base.VerifyException;
import java.util.Collection;
-import org.eclipse.jdt.annotation.Nullable;
import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext.Mutable;
import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext.Mutable;
*/
private static final int REFCOUNT_SWEPT = Integer.MIN_VALUE;
*/
private static final int REFCOUNT_SWEPT = Integer.MIN_VALUE;
+ @Override
+ public abstract StatementContextBase<?, ?, ?> getParentContext();
+
/**
* Acquire a reference on this context. As long as there is at least one reference outstanding,
* {@link #buildEffective()} will not result in {@link #effectiveSubstatements()} being discarded.
/**
* Acquire a reference on this context. As long as there is at least one reference outstanding,
* {@link #buildEffective()} will not result in {@link #effectiveSubstatements()} being discarded.
abstract boolean noImplictRef();
abstract boolean noImplictRef();
- abstract @Nullable ReactorStmtCtx<?, ?, ?> parentStmtCtx();
-
// Called when this statement does not have an implicit reference and have reached REFCOUNT_NONE
private void sweepOnDecrement() {
LOG.trace("Sweeping on decrement {}", this);
// Called when this statement does not have an implicit reference and have reached REFCOUNT_NONE
private void sweepOnDecrement() {
LOG.trace("Sweeping on decrement {}", this);
}
// Propagate towards parent if there is one
}
// Propagate towards parent if there is one
- final ReactorStmtCtx<?, ?, ?> parent = parentStmtCtx();
+ final ReactorStmtCtx<?, ?, ?> parent = getParentContext();
if (parent != null) {
parent.sweepOnChildDecrement();
}
if (parent != null) {
parent.sweepOnChildDecrement();
}
if (noParentRefcount()) {
LOG.trace("Cleanup {} of parent {}", refcount, this);
if (sweepState()) {
if (noParentRefcount()) {
LOG.trace("Cleanup {} of parent {}", refcount, this);
if (sweepState()) {
- final ReactorStmtCtx<?, ?, ?> parent = parentStmtCtx();
+ final ReactorStmtCtx<?, ?, ?> parent = getParentContext();
if (parent != null) {
parent.sweepOnChildDecrement();
}
if (parent != null) {
parent.sweepOnChildDecrement();
}
// FIXME: cache the resolution of this
private boolean noParentRefcount() {
// FIXME: cache the resolution of this
private boolean noParentRefcount() {
- final ReactorStmtCtx<?, ?, ?> parent = parentStmtCtx();
+ final ReactorStmtCtx<?, ?, ?> parent = getParentContext();
if (parent != null) {
// There are three possibilities:
// - REFCOUNT_NONE, in which case we need to search next parent
if (parent != null) {
// There are three possibilities:
// - REFCOUNT_NONE, in which case we need to search next parent
LOG.trace("Child refcount {}", refcount);
if (refcount == REFCOUNT_NONE) {
sweepDone();
LOG.trace("Child refcount {}", refcount);
if (refcount == REFCOUNT_NONE) {
sweepDone();
- final ReactorStmtCtx<?, ?, ?> parent = parentStmtCtx();
+ final ReactorStmtCtx<?, ?, ?> parent = getParentContext();
LOG.trace("Propagating to parent {}", parent);
if (parent != null && parent.isAwaitingChildren()) {
parent.sweepOnChildDone();
LOG.trace("Propagating to parent {}", parent);
if (parent != null && parent.isAwaitingChildren()) {
parent.sweepOnChildDone();
this.completedPhase = completedPhase;
}
this.completedPhase = completedPhase;
}
- @Override
- public abstract StatementContextBase<?, ?, ?> getParentContext();
-
/**
* Returns the model root for this statement.
*
/**
* Returns the model root for this statement.
*
return effectiveInstance != null || !isSupportedToBuildEffective();
}
return effectiveInstance != null || !isSupportedToBuildEffective();
}
- @Override
- final ReactorStmtCtx<?, ?, ?> parentStmtCtx() {
- return getParentContext();
- }
-
/**
* Config statements are not all that common which means we are performing a recursive search towards the root
* every time {@link #isConfiguration()} is invoked. This is quite expensive because it causes a linear search
/**
* Config statements are not all that common which means we are performing a recursive search towards the root
* every time {@link #isConfiguration()} is invoked. This is quite expensive because it causes a linear search