private final SubstatementValidator validator;
private DefaultDenyAllStatementSupport(final StatementDefinition definition) {
- super(definition);
+ super(definition, CopyPolicy.CONTEXT_INDEPENDENT);
this.validator = SubstatementValidator.builder(definition).build();
}
protected BaseBooleanStatementSupport(final StatementDefinition publicDefinition,
final E emptyEffectiveFalse, final E emptyEffectiveTrue) {
- super(publicDefinition);
+ super(publicDefinition, CopyPolicy.CONTEXT_INDEPENDENT);
this.emptyEffectiveFalse = requireNonNull(emptyEffectiveFalse);
this.emptyEffectiveTrue = requireNonNull(emptyEffectiveTrue);
emptyDeclaredFalse = requireNonNull(emptyEffectiveFalse.getDeclared());
* reasonably interned and it dominates the {@link EffectiveStatement} implementation. Typical examples include
* {@code position} and {@code value} statements, which typically do not have substatements and are based on simple
* types.
+ *
+ * <p>
+ * Note: use of this base class implies context-independence.
*/
@Beta
public abstract class BaseInternedStatementSupport<A, D extends DeclaredStatement<A>,
});
protected BaseInternedStatementSupport(final StatementDefinition publicDefinition) {
- super(publicDefinition);
+ super(publicDefinition, CopyPolicy.CONTEXT_INDEPENDENT);
}
@Override
super(publicDefinition);
}
+ protected BaseStatementSupport(final StatementDefinition publicDefinition, final CopyPolicy copyPolicy) {
+ super(publicDefinition, copyPolicy);
+ }
+
@Override
public final D createDeclared(final StmtContext<A, D, ?> ctx) {
final ImmutableList<? extends DeclaredStatement<?>> substatements = ctx.declaredSubstatements().stream()
import org.opendaylight.yangtools.yang.model.api.meta.StatementDefinition;
/**
- * Specialization of {@link BaseStatementSupport} for String statement arguments.
+ * Specialization of {@link BaseStatementSupport} for String statement arguments. Note this implies context-independence
+ * by default.
*
* @param <D> Declared Statement representation
* @param <E> Effective Statement representation
public abstract class BaseStringStatementSupport<D extends DeclaredStatement<String>,
E extends EffectiveStatement<String, D>> extends BaseStatementSupport<String, D, E> {
protected BaseStringStatementSupport(final StatementDefinition publicDefinition) {
- super(publicDefinition);
+ super(publicDefinition, CopyPolicy.CONTEXT_INDEPENDENT);
}
}
}
private FractionDigitsStatementSupport() {
- super(YangStmtMapping.FRACTION_DIGITS);
+ super(YangStmtMapping.FRACTION_DIGITS, CopyPolicy.CONTEXT_INDEPENDENT);
}
public static FractionDigitsStatementSupport getInstance() {
private static final IfFeatureStatementSupport INSTANCE = new IfFeatureStatementSupport();
private IfFeatureStatementSupport() {
- super(YangStmtMapping.IF_FEATURE);
+ super(YangStmtMapping.IF_FEATURE, CopyPolicy.CONTEXT_INDEPENDENT);
}
public static IfFeatureStatementSupport getInstance() {
private static final LengthStatementSupport INSTANCE = new LengthStatementSupport();
private LengthStatementSupport() {
- super(YangStmtMapping.LENGTH);
+ super(YangStmtMapping.LENGTH, CopyPolicy.CONTEXT_INDEPENDENT);
}
public static LengthStatementSupport getInstance() {
private static final MaxElementsStatementSupport INSTANCE = new MaxElementsStatementSupport();
private MaxElementsStatementSupport() {
- super(YangStmtMapping.MAX_ELEMENTS);
+ super(YangStmtMapping.MAX_ELEMENTS, CopyPolicy.CONTEXT_INDEPENDENT);
}
public static MaxElementsStatementSupport getInstance() {
private static final Logger LOG = LoggerFactory.getLogger(AbstractPatternStatementSupport.class);
AbstractPatternStatementSupport() {
- super(YangStmtMapping.PATTERN);
+ super(YangStmtMapping.PATTERN, CopyPolicy.CONTEXT_INDEPENDENT);
}
@Override
private static final RevisionDateStatementSupport INSTANCE = new RevisionDateStatementSupport();
private RevisionDateStatementSupport() {
- super(YangStmtMapping.REVISION_DATE);
+ super(YangStmtMapping.REVISION_DATE, CopyPolicy.CONTEXT_INDEPENDENT);
}
public static RevisionDateStatementSupport getInstance() {
new EmptyStatusEffectiveStatement(EMPTY_OBSOLETE_DECL);
private StatusStatementSupport() {
- super(YangStmtMapping.STATUS);
+ super(YangStmtMapping.STATUS, CopyPolicy.CONTEXT_INDEPENDENT);
}
public static StatusStatementSupport getInstance() {
new EmptyYangVersionEffectiveStatement(EMPTY_VER1_1_DECL);
private YangVersionStatementSupport() {
- super(YangStmtMapping.YANG_VERSION);
+ super(YangStmtMapping.YANG_VERSION, CopyPolicy.CONTEXT_INDEPENDENT);
}
public static YangVersionStatementSupport getInstance() {
import static com.google.common.base.Preconditions.checkArgument;
import static java.util.Objects.requireNonNull;
+import com.google.common.annotations.Beta;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
+import org.opendaylight.yangtools.yang.common.QNameModule;
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.StatementDefinition;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext.Mutable;
/**
* Class providing necessary support for processing a YANG statement. This class is intended to be subclassed
implements StatementDefinition, StatementFactory<A, D, E>, StatementSupport<A, D, E> {
private final @NonNull StatementDefinition type;
+ private final @NonNull CopyPolicy copyPolicy;
- protected AbstractStatementSupport(final StatementDefinition publicDefinition) {
+ @Beta
+ protected AbstractStatementSupport(final StatementDefinition publicDefinition, final CopyPolicy copyPolicy) {
this.type = requireNonNull(publicDefinition);
+ this.copyPolicy = requireNonNull(copyPolicy);
checkArgument(publicDefinition != this);
}
+ protected AbstractStatementSupport(final StatementDefinition publicDefinition) {
+ this(publicDefinition, CopyPolicy.DECLARED_COPY);
+ }
+
@Override
public final StatementDefinition getPublicView() {
return type;
}
+ @Override
+ public CopyPolicy applyCopyPolicy(final Mutable<?, ?, ?> stmt, final Mutable<?, ?, ?> parent,
+ final CopyType copyType, final QNameModule targetModule) {
+ return copyPolicy;
+ }
+
@Override
public void onStatementAdded(final StmtContext.Mutable<A, D, E> stmt) {
// NOOP for most implementations
super(publicDefinition);
}
+ protected AbstractVoidStatementSupport(final StatementDefinition publicDefinition, final CopyPolicy copyPolicy) {
+ super(publicDefinition, copyPolicy);
+ }
+
@Override
public final Void parseArgumentValue(final StmtContext<?, ?, ?> ctx, final String value) {
return null;
}
@Override
- public CopyPolicy applyCopyPolicy(final Mutable<?, ?, ?> stmt,
- final Mutable<?, ?, ?> parent, final CopyType type, final QNameModule targetModule) {
- return delegate().applyCopyPolicy(stmt, parent, type, targetModule);
+ public CopyPolicy applyCopyPolicy(final Mutable<?, ?, ?> stmt, final Mutable<?, ?, ?> parent,
+ final CopyType copyType, final QNameModule targetModule) {
+ return delegate().applyCopyPolicy(stmt, parent, copyType, targetModule);
}
}
*
* @param stmt Context of statement to be copied statement.
* @param parent Parent statement context
- * @param type Type of copy being performed
+ * @param copyType Type of copy being performed
* @param targetModule Target module, if present
* @return Policy that needs to be applied to the copy operation of this statement.
*/
// FIXME: YANGTOOLS-694: clarify targetModule semantics (does null mean 'same as declared'?)
default @NonNull CopyPolicy applyCopyPolicy(final Mutable<?, ?, ?> stmt, final Mutable<?, ?, ?> parent,
- final CopyType type, @Nullable final QNameModule targetModule) {
+ final CopyType copyType, @Nullable final QNameModule targetModule) {
// Most of statement supports will just want to copy the statement
// FIXME: YANGTOOLS-694: that is not strictly true. Subclasses of this should indicate if they are themselves
// copy-sensitive: