import com.google.common.annotations.Beta;
import com.google.common.base.VerifyException;
-import java.util.Collection;
+import java.util.List;
import java.util.Optional;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
public abstract class StatementSupport<A, D extends DeclaredStatement<A>, E extends EffectiveStatement<A, D>>
implements StatementFactory<A, D, E> {
/**
- * A baseline class for implementing the {@link StatementFactory#canReuseCurrent(Current, Current, Collection)}
+ * A baseline class for implementing the {@link StatementFactory#canReuseCurrent(Current, Current, List)}
* contract in a manner which is consistent with a statement's {@link CopyPolicy}.
*
* @param <A> Argument type
}
abstract boolean canReuseCurrent(@NonNull Current<A, D> copy, @NonNull Current<A, D> current,
- @NonNull Collection<? extends EffectiveStatement<?, ?>> substatements);
+ @NonNull List<? extends EffectiveStatement<?, ?>> substatements);
private static final class AlwaysFail<A, D extends DeclaredStatement<A>> extends StatementPolicy<A, D> {
static final @NonNull AlwaysFail<?, ?> IGNORE = new AlwaysFail<>(CopyPolicy.IGNORE);
@Override
boolean canReuseCurrent(final Current<A, D> copy, final Current<A, D> current,
- final Collection<? extends EffectiveStatement<?, ?>> substatements) {
+ final List<? extends EffectiveStatement<?, ?>> substatements) {
throw new VerifyException("This implementation should never be invoked");
}
}
@Override
boolean canReuseCurrent(final Current<A, D> copy, final Current<A, D> current,
- final Collection<? extends EffectiveStatement<?, ?>> substatements) {
+ final List<? extends EffectiveStatement<?, ?>> substatements) {
return equality.canReuseCurrent(copy, current, substatements);
}
}
public interface StatementEquality<A, D extends DeclaredStatement<A>> {
/**
* Determine whether {@code current} statement has the same semantics as the provided copy. See the contract
- * specification of {@link StatementFactory#canReuseCurrent(Current, Current, Collection)}.
+ * specification of {@link StatementFactory#canReuseCurrent(Current, Current, List)}.
*
* @param copy Copy of current effective context
* @param current Current effective context
* @return True if {@code current} can be reused in place of {@code copy}, false if the copy needs to be used.
*/
boolean canReuseCurrent(@NonNull Current<A, D> copy, @NonNull Current<A, D> current,
- @NonNull Collection<? extends EffectiveStatement<?, ?>> substatements);
+ @NonNull List<? extends EffectiveStatement<?, ?>> substatements);
}
+ /**
+ * Projection of {@link StatementSupport}s available within a particular source. This namespace is purely virtual
+ * and its behaviour corresponds to {@link NamespaceBehaviour#rootStatementLocal(ParserNamespace)} and is always
+ * available.
+ * Its contents are derived from {@link StatementSupportBundle}s active in the current {@link ModelProcessingPhase}
+ * as well as {@link StatementDefinitions} and {@link StmtContext#yangVersion()} of the source root statement.
+ */
+ @Beta
+ public static final @NonNull ParserNamespace<QName, StatementSupport<?, ?, ?>> NAMESPACE =
+ new ParserNamespace<>("statementSupports");
+
private final @NonNull StatementPolicy<A, D> policy;
private final @NonNull StatementDefinition publicDefinition;
private final @NonNull CopyPolicy copyPolicy;
@Beta
protected StatementSupport(final StatementSupport<A, D, E> delegate) {
checkArgument(delegate != this);
- this.publicDefinition = delegate.publicDefinition;
- this.policy = delegate.policy;
- this.copyPolicy = delegate.copyPolicy;
+ publicDefinition = delegate.publicDefinition;
+ policy = delegate.policy;
+ copyPolicy = delegate.copyPolicy;
}
@Beta
protected StatementSupport(final StatementDefinition publicDefinition, final StatementPolicy<A, D> policy) {
this.publicDefinition = requireNonNull(publicDefinition);
this.policy = requireNonNull(policy);
- this.copyPolicy = policy.copyPolicy;
+ copyPolicy = policy.copyPolicy;
}
/**
@Override
public final boolean canReuseCurrent(final Current<A, D> copy, final Current<A, D> current,
- final Collection<? extends EffectiveStatement<?, ?>> substatements) {
+ final List<? extends EffectiveStatement<?, ?>> substatements) {
return policy.canReuseCurrent(copy, current, substatements);
}
}
public final @Nullable QName argumentName() {
- return publicDefinition.getArgumentDefinition().map(ArgumentDefinition::getArgumentName).orElse(null);
+ return publicDefinition.getArgumentDefinition().map(ArgumentDefinition::argumentName).orElse(null);
}
public final @NonNull Optional<ArgumentDefinition> getArgumentDefinition() {