import com.google.common.annotations.Beta;
import java.util.Set;
import org.eclipse.jdt.annotation.NonNull;
-import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Relative;
+import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Descendant;
/**
* Interface describing YANG 'unique' constraint.
*/
@Beta
public interface UniqueConstraint {
- @NonNull Set<Relative> getTag();
+ @NonNull Set<Descendant> getTag();
}
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
/**
- * Represents unique path to the every schema node inside the schema node identifier namespace.
+ * Represents unique path to the every schema node inside the schema node identifier namespace. This concept is defined
+ * in <a href="https://tools.ietf.org/html/rfc7950#section-6.5">RFC7950</a>.
*/
public abstract class SchemaNodeIdentifier implements Immutable {
-
/**
* An absolute schema node identifier.
*/
}
/**
- * A relative schema node identifier.
+ * A descendant schema node identifier.
*/
- public static final class Relative extends SchemaNodeIdentifier {
- private Relative(final SchemaNodeIdentifier parent, final QName qname) {
+ public static final class Descendant extends SchemaNodeIdentifier {
+ private Descendant(final SchemaNodeIdentifier parent, final QName qname) {
super(parent, qname);
}
}
@Override
- public Relative createChild(final QName element) {
- return new Relative(this, requireNonNull(element));
+ public Descendant createChild(final QName element) {
+ return new Descendant(this, requireNonNull(element));
}
}
/**
* Shared instance of the "same" relative schema node.
*/
- public static final Relative SAME = new Relative(null, null);
+ public static final Descendant SAME = new Descendant(null, null);
/**
* Parent path.
* path from the schema node towards the root.
*/
public Iterable<QName> getPathTowardsRoot() {
- return () -> new UnmodifiableIterator<QName>() {
+ return () -> new UnmodifiableIterator<>() {
private SchemaNodeIdentifier current = SchemaNodeIdentifier.this;
@Override
import com.google.common.annotations.Beta;
import java.util.Set;
import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
-import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Relative;
+import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Descendant;
@Beta
-public interface UniqueEffectiveStatement extends EffectiveStatement<Set<Relative>, UniqueStatement> {
+public interface UniqueEffectiveStatement extends EffectiveStatement<Set<Descendant>, UniqueStatement> {
}
import java.util.Set;
import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
-import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Relative;
+import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Descendant;
-public interface UniqueStatement extends DeclaredStatement<Set<SchemaNodeIdentifier.Relative>> {
+public interface UniqueStatement extends DeclaredStatement<Set<SchemaNodeIdentifier.Descendant>> {
- default Set<Relative> getTag() {
+ default Set<Descendant> getTag() {
// FIXME: YANGTOOLS-908: verifyNotNull() should not be needed here
return verifyNotNull(argument());
}
import java.util.Set;
import org.opendaylight.yangtools.yang.model.api.UniqueConstraint;
-import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Relative;
+import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Descendant;
import org.opendaylight.yangtools.yang.model.api.stmt.UniqueEffectiveStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.UniqueStatement;
import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.DeclaredEffectiveStatementBase;
import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
-final class UniqueEffectiveStatementImpl extends DeclaredEffectiveStatementBase<Set<Relative>, UniqueStatement>
+final class UniqueEffectiveStatementImpl extends DeclaredEffectiveStatementBase<Set<Descendant>, UniqueStatement>
implements UniqueConstraint, UniqueEffectiveStatement {
- UniqueEffectiveStatementImpl(final StmtContext<Set<Relative>, UniqueStatement, ?> ctx) {
+ UniqueEffectiveStatementImpl(final StmtContext<Set<Descendant>, UniqueStatement, ?> ctx) {
super(ctx);
}
@Override
- public Set<Relative> getTag() {
+ public Set<Descendant> getTag() {
// FIXME: YANGTOOLS-908: verifyNotNull() should not be needed here
return verifyNotNull(argument());
}
package org.opendaylight.yangtools.yang.parser.rfc7950.stmt.unique;
import java.util.Set;
-import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Relative;
+import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Descendant;
import org.opendaylight.yangtools.yang.model.api.stmt.UniqueStatement;
import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractDeclaredStatement;
import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
-final class UniqueStatementImpl extends AbstractDeclaredStatement<Set<Relative>> implements UniqueStatement {
- UniqueStatementImpl(final StmtContext<Set<Relative>, UniqueStatement, ?> context) {
+final class UniqueStatementImpl extends AbstractDeclaredStatement<Set<Descendant>> implements UniqueStatement {
+ UniqueStatementImpl(final StmtContext<Set<Descendant>, UniqueStatement, ?> context) {
super(context);
}
}
import java.util.regex.Pattern;
import org.opendaylight.yangtools.yang.model.api.YangStmtMapping;
import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier;
-import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Relative;
+import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Descendant;
import org.opendaylight.yangtools.yang.model.api.stmt.UniqueEffectiveStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.UniqueStatement;
import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.ArgumentUtils;
import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
public final class UniqueStatementSupport
- extends AbstractStatementSupport<Set<Relative>, UniqueStatement, UniqueEffectiveStatement> {
+ extends AbstractStatementSupport<Set<Descendant>, UniqueStatement, UniqueEffectiveStatement> {
/**
* Support 'sep' ABNF rule in RFC7950 section 14. CRLF pattern is used to squash line-break from CRLF to LF form
* and then we use SEP_SPLITTER, which can operate on single characters.
}
@Override
- public Set<Relative> parseArgumentValue(final StmtContext<?, ?, ?> ctx, final String value) {
- final Set<Relative> uniqueConstraints = parseUniqueConstraintArgument(ctx, value);
+ public Set<Descendant> parseArgumentValue(final StmtContext<?, ?, ?> ctx, final String value) {
+ final Set<Descendant> uniqueConstraints = parseUniqueConstraintArgument(ctx, value);
SourceException.throwIf(uniqueConstraints.isEmpty(), ctx.getStatementSourceReference(),
"Invalid argument value '%s' of unique statement. The value must contains at least "
+ "one descendant schema node identifier.", value);
}
@Override
- public UniqueStatement createDeclared(final StmtContext<Set<Relative>, UniqueStatement, ?> ctx) {
+ public UniqueStatement createDeclared(final StmtContext<Set<Descendant>, UniqueStatement, ?> ctx) {
return new UniqueStatementImpl(ctx);
}
@Override
public UniqueEffectiveStatement createEffective(
- final StmtContext<Set<Relative>, UniqueStatement, UniqueEffectiveStatement> ctx) {
+ final StmtContext<Set<Descendant>, UniqueStatement, UniqueEffectiveStatement> ctx) {
return new UniqueEffectiveStatementImpl(ctx);
}
return SUBSTATEMENT_VALIDATOR;
}
- private static Set<Relative> parseUniqueConstraintArgument(final StmtContext<?, ?, ?> ctx,
+ private static Set<Descendant> parseUniqueConstraintArgument(final StmtContext<?, ?, ?> ctx,
final String argumentValue) {
// deal with 'line-break' rule, which is either "\n" or "\r\n", but not "\r"
final String nocrlf = CRLF_PATTERN.matcher(argumentValue).replaceAll("\n");
- final Set<Relative> uniqueConstraintNodes = new HashSet<>();
+ final Set<Descendant> uniqueConstraintNodes = new HashSet<>();
for (final String uniqueArgToken : SEP_SPLITTER.split(nocrlf)) {
final SchemaNodeIdentifier nodeIdentifier = ArgumentUtils.nodeIdentifierFromPath(ctx, uniqueArgToken);
SourceException.throwIf(nodeIdentifier.isAbsolute(), ctx.getStatementSourceReference(),
"Unique statement argument '%s' contains schema node identifier '%s' "
+ "which is not in the descendant node identifier form.", argumentValue, uniqueArgToken);
- uniqueConstraintNodes.add((Relative) nodeIdentifier);
+ uniqueConstraintNodes.add((Descendant) nodeIdentifier);
}
return ImmutableSet.copyOf(uniqueConstraintNodes);
}
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.opendaylight.yangtools.yang.model.api.UniqueConstraint;
import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier;
-import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Relative;
+import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Descendant;
import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
public class Bug5946Test {
Collection<? extends UniqueConstraint> simpleUniqueConstraints = getListConstraints(context, SIMPLE_UNIQUE);
assertNotNull(simpleUniqueConstraints);
assertEquals(1, simpleUniqueConstraints.size());
- Collection<Relative> simpleUniqueConstraintTag = simpleUniqueConstraints.iterator().next().getTag();
+ Collection<Descendant> simpleUniqueConstraintTag = simpleUniqueConstraints.iterator().next().getTag();
assertTrue(simpleUniqueConstraintTag.contains(L1_ID));
assertTrue(simpleUniqueConstraintTag.contains(C_L3_ID));
boolean l1cl3 = false;
boolean cl3l2 = false;
for (UniqueConstraint uniqueConstraint : multipleUniqueConstraints) {
- Collection<Relative> uniqueConstraintTag = uniqueConstraint.getTag();
+ Collection<Descendant> uniqueConstraintTag = uniqueConstraint.getTag();
if (uniqueConstraintTag.contains(L1_ID) && uniqueConstraintTag.contains(L2_ID)) {
l1l2 = true;
} else if (uniqueConstraintTag.contains(L1_ID) && uniqueConstraintTag.contains(C_L3_ID)) {
fail("ReactorException should be thrown");
} catch (final ReactorException e) {
assertThat(e.getCause().getMessage(), containsString("Error in module 'test4' in the refine of uses "
- + "'Relative{path=[(urn:simple.container.demo)node]}': can not perform refine of 'PRESENCE' for"
+ + "'Descendant{path=[(urn:simple.container.demo)node]}': can not perform refine of 'PRESENCE' for"
+ " the target 'LEAF_LIST'."));
}
}