return false;
}
+ @Override
+ public boolean isMandatory() {
+ return false;
+ }
+
@Override
public ConstraintDefinition getConstraints() {
return null;
public ContainerSchemaNode getSchemaOfAnyXmlData() {
return contentSchema;
}
+
}
}
import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.MandatoryAware;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
findMandatoryNodes(builder, id.node(NodeIdentifier.create(child.getQName())), container, type);
}
} else {
+ final boolean mandatory = child instanceof MandatoryAware && ((MandatoryAware) child).isMandatory();
final ConstraintDefinition constraints = child.getConstraints();
final Integer minElements = constraints.getMinElements();
- if (constraints.isMandatory() || minElements != null && minElements.intValue() > 0) {
+ if (mandatory || minElements != null && minElements.intValue() > 0) {
final YangInstanceIdentifier childId = id.node(NodeIdentifier.create(child.getQName()));
LOG.debug("Adding mandatory child {}", childId);
builder.add(childId.toOptimized());
result = prime * result + Objects.hashCode(def.getMustConstraints());
result = prime * result + Objects.hashCode(def.getMinElements());
result = prime * result + Objects.hashCode(def.getMaxElements());
- result = prime * result + Boolean.hashCode(def.isMandatory());
return result;
}
return false;
}
final ConstraintDefinition other = (ConstraintDefinition) obj;
- if (def.isMandatory() != other.isMandatory()) {
- return false;
- }
if (!Objects.equals(def.getWhenCondition(), other.getWhenCondition())) {
return false;
}
return MoreObjects.toStringHelper(def).omitNullValues()
.add("whenCondition", def.getWhenCondition().orElse(null))
.add("mustConstraints", def.getMustConstraints())
- .add("mandatory", def.isMandatory())
.add("minElements", def.getMinElements())
.add("maxElements", def.getMaxElements()).toString();
}
@Override
public ConstraintDefinition getConstraints() {
- return EmptyConstraintDefinition.create(false);
+ return EmptyConstraintDefinition.getInstance();
}
@Nonnull
/**
* Utility holder for constraint definitions which do not really constrain anything.
*/
-public abstract class EmptyConstraintDefinition implements ConstraintDefinition {
- private static final EmptyConstraintDefinition MANDATORY = new EmptyConstraintDefinition() {
- @Override
- public boolean isMandatory() {
- return true;
- }
- };
- private static final EmptyConstraintDefinition OPTIONAL = new EmptyConstraintDefinition() {
- @Override
- public boolean isMandatory() {
- return false;
- }
- };
+public final class EmptyConstraintDefinition implements ConstraintDefinition {
+ private static final EmptyConstraintDefinition INSTANCE = new EmptyConstraintDefinition();
private EmptyConstraintDefinition() {
// Hidden on purpose
}
- public static EmptyConstraintDefinition create(final boolean mandatory) {
- return mandatory ? MANDATORY : OPTIONAL;
+ public static EmptyConstraintDefinition getInstance() {
+ return INSTANCE;
}
@Override
- public final Optional<RevisionAwareXPath> getWhenCondition() {
+ public Optional<RevisionAwareXPath> getWhenCondition() {
return Optional.empty();
}
@Override
- public final Set<MustDefinition> getMustConstraints() {
+ public Set<MustDefinition> getMustConstraints() {
return ImmutableSet.of();
}
@Override
- public final Integer getMinElements() {
+ public Integer getMinElements() {
return null;
}
@Override
- public final Integer getMaxElements() {
+ public Integer getMaxElements() {
return null;
}
@Override
- public final int hashCode() {
+ public int hashCode() {
return ConstraintDefinitions.hashCode(this);
}
@Override
- public final boolean equals(final Object obj) {
+ public boolean equals(final Object obj) {
return ConstraintDefinitions.equals(this, obj);
}
@Override
- public final String toString() {
+ public String toString() {
return ConstraintDefinitions.toString(this);
}
}
import java.util.Optional;
/**
- * The "anydata" statement defines an interior node in the schema tree.
- * It takes one argument, which is an identifier, followed by a block of
- * substatements that holds detailed anydata information.
+ * The "anydata" statement defines an interior node in the schema tree. It takes one argument, which is an identifier,
+ * followed by a block of substatements that holds detailed anydata information.
*
* <p>
- * The "anydata" statement is used to represent an unknown set of nodes
- * that can be modeled with YANG, except anyxml, but for which the data
- * model is not known at module design time. It is possible, though not
- * required, for the data model for anydata content to become known
- * through protocol signaling or other means that are outside the scope
+ * The "anydata" statement is used to represent an unknown set of nodes that can be modeled with YANG, except anyxml,
+ * but for which the data model is not known at module design time. It is possible, though not required, for the data
+ * model for anydata content to become known through protocol signaling or other means that are outside the scope
* of this document.
*/
@Beta
-public interface AnyDataSchemaNode extends DataSchemaNode {
+public interface AnyDataSchemaNode extends DataSchemaNode, MandatoryAware {
/**
* Schema of data.
*
package org.opendaylight.yangtools.yang.model.api;
/**
- * The "anyxml" interface defines an interior node in the schema tree. It takes
- * one argument, which is an identifier represented by QName inherited from
- * {@link SchemaNode}, followed by a block of substatements that holds detailed
- * anyxml information. The substatements are defined in {@link DataSchemaNode} <br>
- * <br>
- * This interface was modeled according to definition in <a
- * href="https://tools.ietf.org/html/rfc6020#section-7.10">[RFC-6020] The anyxml
- * Statement</a>
+ * The "anyxml" interface defines an interior node in the schema tree. It takes one argument, which is an identifier
+ * represented by QName inherited from {@link SchemaNode}, followed by a block of substatements that holds detailed
+ * anyxml information. The substatements are defined in {@link DataSchemaNode}.
+ *
+ * <p>
+ * This interface was modeled according to definition in
+ * <a href="https://tools.ietf.org/html/rfc6020#section-7.10">[RFC-6020] The anyxml Statement</a>
*/
-public interface AnyXmlSchemaNode extends DataSchemaNode {
+public interface AnyXmlSchemaNode extends DataSchemaNode, MandatoryAware {
}
* A ChoiceSchemaNode defines a set of alternatives. It consists of a number of branches defined as
* ChoiceCaseSchemaNode objects.
*/
-public interface ChoiceSchemaNode extends DataSchemaNode, AugmentationTarget {
+public interface ChoiceSchemaNode extends DataSchemaNode, AugmentationTarget, MandatoryAware {
/**
* Returns cases of choice, keyed by their {@link SchemaNode#getQName()}. Returned map does not contain null keys
* nor values.
* then the method returns <code>null</code> value.
*/
public interface ConstraintDefinition extends MustConstraintAware, WhenConditionAware {
- /**
- * Expreses if the presence of the data element for which this constraint is
- * specified is|isn't required.
- *
- * <p>
- * Contains the value of the <b>mandatory</b> YANG substatement.
- * It is used with YANG statements leaf, choice, anyxml, deviate.
- *
- * @return boolean value:
- * <ul>
- * <li>true - if <code>mandatory</code> YANG keyword argument =
- * <i>true</i></li>
- * <li>false - if <code>mandatory</code> YANG keyword argument =
- * <i>false</i></li>
- * </ul>
- */
- boolean isMandatory();
-
/**
* Returns the minimum required number of data elements for node where this
* constraint is specified.
* Since we are presenting the effective model of the world, the information dictated by 'default' and 'units'
* substatements is captured in the type returned via {@link #getType()}.
*/
-public interface LeafSchemaNode extends TypedSchemaNode {
+public interface LeafSchemaNode extends TypedSchemaNode, MandatoryAware {
}
--- /dev/null
+/*
+ * Copyright (c) 2017 Pantheon Technologies, s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.model.api;
+
+/**
+ * Mix-in interface for {@link SchemaNode}s which can have a {@code mandatory} statement.
+ *
+ * @author Robert Varga
+ */
+public interface MandatoryAware {
+
+ /**
+ * Return whether this node is mandatory or not. Note this reflects the declared model, as defined by 'mandatory'
+ * statement, not the effective model. This notably means this attribute does not mirror the definition of
+ * {@code mandatory node} as per <a href="https://tools.ietf.org/html/rfc7950#page-14">RFC7950 Terminology</a>.
+ *
+ * @return True if this node is marked as mandatory.
+ */
+ boolean isMandatory();
+}
* <dd>{@link org.opendaylight.yangtools.yang.model.api.ListSchemaNode}
*
* <dt>mandatory
- * <dd>{@link org.opendaylight.yangtools.yang.model.api.ConstraintDefinition#isMandatory()}
+ * <dd>{@link org.opendaylight.yangtools.yang.model.api.MandatoryAware#isMandatory()}
*
* <dt>max-elements
* <dd>{@link org.opendaylight.yangtools.yang.model.api.ConstraintDefinition#getMinElements()}
emitMustNodes(child.getConstraints().getMustConstraints());
child.getType().getDefaultValue().ifPresent(this::emitDefaultNode);
emitConfigNode(child.isConfiguration());
- emitMandatoryNode(child.getConstraints().isMandatory());
+ emitMandatoryNode(child.isMandatory());
emitDocumentedNode(child);
emitUnknownStatementNodes(child.getUnknownSchemaNodes());
super.writer.endNode();
// FIXME: BUG-2444: *(ifFeatureNode )
// FIXME: BUG-2444: defaultNode //Optional
emitConfigNode(choice.isConfiguration());
- emitMandatoryNode(choice.getConstraints().isMandatory());
+ emitMandatoryNode(choice.isMandatory());
emitDocumentedNode(choice);
for (final ChoiceCaseNode caze : choice.getCases().values()) {
// TODO: emit short case?
// FIXME: BUG-2444: *(ifFeatureNode )
emitMustNodes(dataSchemaNode.getConstraints().getMustConstraints());
emitConfigNode(dataSchemaNode.isConfiguration());
- emitMandatoryNode(dataSchemaNode.getConstraints().isMandatory());
emitDocumentedNode(dataSchemaNode);
emitUnknownStatementNodes(dataSchemaNode.getUnknownSchemaNodes());
}
emitConfigNode(value.isConfiguration());
}
emitDocumentedNodeRefine(original, value);
- if (Objects.deepEquals(original.getConstraints().isMandatory(), value.getConstraints().isMandatory())) {
- emitMandatoryNode(value.getConstraints().isMandatory());
+ if (Objects.deepEquals(original.isMandatory(), value.isMandatory())) {
+ emitMandatoryNode(value.isMandatory());
}
}
if (Objects.deepEquals(original.isConfiguration(), value.isConfiguration())) {
emitConfigNode(value.isConfiguration());
}
- if (Objects.deepEquals(original.getConstraints().isMandatory(), value.getConstraints().isMandatory())) {
- emitMandatoryNode(value.getConstraints().isMandatory());
+ if (Objects.deepEquals(original.isMandatory(), value.isMandatory())) {
+ emitMandatoryNode(value.isMandatory());
}
emitDocumentedNodeRefine(original, value);
if (Objects.deepEquals(original.isConfiguration(), value.isConfiguration())) {
emitConfigNode(value.isConfiguration());
}
- if (Objects.deepEquals(original.getConstraints().isMandatory(), value.getConstraints().isMandatory())) {
- emitMandatoryNode(value.getConstraints().isMandatory());
+ if (Objects.deepEquals(original.isMandatory(), value.isMandatory())) {
+ emitMandatoryNode(value.isMandatory());
}
emitDocumentedNodeRefine(original, value);
implements AnyXmlSchemaNode, DerivableSchemaNode {
private final AnyXmlSchemaNode original;
+ private final boolean mandatory;
public AnyXmlEffectiveStatementImpl(
final StmtContext<QName, AnyxmlStatement, EffectiveStatement<QName, AnyxmlStatement>> ctx) {
super(ctx);
this.original = (AnyXmlSchemaNode) ctx.getOriginalCtx().map(StmtContext::buildEffective).orElse(null);
+ final MandatoryEffectiveStatement mandatoryStmt = firstEffective(MandatoryEffectiveStatement.class);
+ mandatory = mandatoryStmt == null ? false : mandatoryStmt.argument().booleanValue();
+ }
+
+ @Override
+ public boolean isMandatory() {
+ return mandatory;
}
@Override
private final SortedMap<QName, ChoiceCaseNode> cases;
private final ChoiceCaseNode defaultCase;
private final ChoiceSchemaNode original;
+ private final boolean mandatory;
public ChoiceEffectiveStatementImpl(
final StmtContext<QName, ChoiceStatement, EffectiveStatement<QName, ChoiceStatement>> ctx) {
} else {
defaultCase = null;
}
+
+ final MandatoryEffectiveStatement mandatoryStmt = firstEffective(MandatoryEffectiveStatement.class);
+ mandatory = mandatoryStmt == null ? false : mandatoryStmt.argument().booleanValue();
}
private static void resetAugmenting(final DataSchemaNode dataSchemaNode) {
return Optional.ofNullable(defaultCase);
}
+ @Override
+ public boolean isMandatory() {
+ return mandatory;
+ }
+
@Override
public int hashCode() {
final int prime = 31;
private final Set<MustDefinition> mustConstraints;
private final Integer minElements;
private final Integer maxElements;
- private final boolean mandatory;
- private EffectiveConstraintDefinitionImpl(final boolean mandatory, final Integer minElements,
- final Integer maxElements, final RevisionAwareXPath whenCondition,
- final Set<MustDefinition> mustConstraints) {
- this.mandatory = mandatory;
+ private EffectiveConstraintDefinitionImpl(final Integer minElements, final Integer maxElements,
+ final RevisionAwareXPath whenCondition, final Set<MustDefinition> mustConstraints) {
this.minElements = minElements;
this.maxElements = maxElements;
this.whenCondition = whenCondition;
maxElements = null;
}
- final MandatoryEffectiveStatement firstMandatoryStmt = parent.firstEffective(MandatoryEffectiveStatement.class);
- final boolean mandatory = firstMandatoryStmt == null ? minElements != null : firstMandatoryStmt.argument();
-
final Set<MustDefinition> mustSubstatements = ImmutableSet.copyOf(parent.allSubstatementsOfType(
MustDefinition.class));
final WhenEffectiveStatementImpl firstWhenStmt = parent.firstEffective(WhenEffectiveStatementImpl.class);
// Check for singleton instances
if (minElements == null && maxElements == null && mustSubstatements.isEmpty() && firstWhenStmt == null) {
- return EmptyConstraintDefinition.create(mandatory);
+ return EmptyConstraintDefinition.getInstance();
}
- return new EffectiveConstraintDefinitionImpl(mandatory, minElements, maxElements,
+ return new EffectiveConstraintDefinitionImpl(minElements, maxElements,
firstWhenStmt == null ? null : firstWhenStmt.argument(), mustSubstatements);
}
return mustConstraints;
}
- @Override
- public boolean isMandatory() {
- return mandatory;
- }
-
@Override
public Integer getMinElements() {
return minElements;
private final TypeDefinition<?> type;
private final String defaultStr;
private final String unitsStr;
+ private final boolean mandatory;
public LeafEffectiveStatementImpl(
final StmtContext<QName, LeafStatement, EffectiveStatement<QName, LeafStatement>> ctx) {
defaultStr = dflt;
unitsStr = units;
type = builder.build();
+ final MandatoryEffectiveStatement mandatoryStmt = firstEffective(MandatoryEffectiveStatement.class);
+ mandatory = mandatoryStmt == null ? false : mandatoryStmt.argument().booleanValue();
+ }
+
+ @Override
+ public boolean isMandatory() {
+ return mandatory;
}
@Override
import org.opendaylight.yangtools.yang.model.api.stmt.AnydataStatement;
import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.AbstractEffectiveDataSchemaNode;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.MandatoryEffectiveStatement;
/**
* YANG 1.1 AnyData effective statement implementation.
private final AnyDataSchemaNode original;
private final ContainerSchemaNode schema;
+ private final boolean mandatory;
public AnyDataEffectiveStatementImpl(
final StmtContext<QName, AnydataStatement, EffectiveStatement<QName, AnydataStatement>> ctx) {
super(ctx);
this.original = (AnyDataSchemaNode) ctx.getOriginalCtx().map(StmtContext::buildEffective).orElse(null);
+ final MandatoryEffectiveStatement mandatoryStmt = firstEffective(MandatoryEffectiveStatement.class);
+ mandatory = mandatoryStmt == null ? false : mandatoryStmt.argument().booleanValue();
+
/*
* :TODO we need to determine a way how to set schema of AnyData
*/
return Optional.ofNullable(schema);
}
+ @Override
+ public boolean isMandatory() {
+ return mandatory;
+ }
+
@Override
public int hashCode() {
return Objects.hash(getQName(),getPath());
assertNotNull(mandatoryLeaf3);
ConstraintDefinition constraints3 = mandatoryLeaf3.getConstraints();
- assertNotEquals(ConstraintDefinitions.hashCode(constraints2), ConstraintDefinitions.hashCode(constraints3));
- assertFalse(ConstraintDefinitions.equals(constraints2, constraints3));
+ assertEquals(ConstraintDefinitions.hashCode(constraints2), ConstraintDefinitions.hashCode(constraints3));
+ assertTrue(ConstraintDefinitions.equals(constraints2, constraints3));
final LeafSchemaNode mandatoryLeaf4 = (LeafSchemaNode) testModule.getDataChildByName(
QName.create(testModule.getQNameModule(), "mandatory-leaf-4"));
final String constraintsString = ConstraintDefinitions.toString(constraints4);
assertEquals("EffectiveConstraintDefinitionImpl{whenCondition=foo = 'bar', mustConstraints=[bar != 'foo'], "
- + "mandatory=true, minElements=50, maxElements=100}", constraintsString);
+ + "minElements=50, maxElements=100}", constraintsString);
}
}
\ No newline at end of file
final SchemaNode findNode = findNode(schemaContext, ImmutableList.of("root", "grp-leaf"));
assertTrue(findNode instanceof LeafSchemaNode);
final LeafSchemaNode grpLeaf = (LeafSchemaNode) findNode;
- assertFalse(grpLeaf.getConstraints().isMandatory());
+ assertFalse(grpLeaf.isMandatory());
}
@Test
final SchemaNode findNode = findNode(schemaContext, ImmutableList.of("root", "grp-leaf"));
assertTrue(findNode instanceof LeafSchemaNode);
final LeafSchemaNode grpLeaf = (LeafSchemaNode) findNode;
- assertTrue(grpLeaf.getConstraints().isMandatory());
+ assertTrue(grpLeaf.isMandatory());
}
private static Set<IdentitySchemaNode> getIdentities(final SchemaContext schemaContext) {
final LeafSchemaNode barLeaf = (LeafSchemaNode) barModule.getDataChildByName(
QName.create(barModule.getQNameModule(), "bar-leaf"));
assertNotNull(barLeaf);
- assertTrue(barLeaf.getConstraints().isMandatory());
+ assertTrue(barLeaf.isMandatory());
}
}
final AnyXmlSchemaNode myAnyxml = (AnyXmlSchemaNode) barModule.getDataChildByName(
QName.create(barModule.getQNameModule(), "my-anyxml"));
assertNotNull(myAnyxml);
- assertTrue(myAnyxml.getConstraints().isMandatory());
+ assertTrue(myAnyxml.isMandatory());
assertEquals(2, myAnyxml.getUnknownSchemaNodes().size());
}
QName.create(barModule.getQNameModule(), "my-choice"));
assertNotNull(myChoice);
- assertFalse(myChoice.getConstraints().isMandatory());
+ assertFalse(myChoice.isMandatory());
assertEquals(1, myChoice.getUnknownSchemaNodes().size());
assertEquals("new arg", myChoice.getUnknownSchemaNodes().iterator().next().getNodeParameter());
assertNotNull(choiceInContainerNode);
ChoiceSchemaNode choiceSchemaNode = (ChoiceSchemaNode) choiceInContainerNode;
+ assertFalse(choiceSchemaNode.isMandatory());
ConstraintDefinition choiceConstraints = choiceSchemaNode.getConstraints();
- assertFalse(choiceConstraints.isMandatory());
assertTrue(choiceConstraints.getMustConstraints().isEmpty());
}
assertNotNull(choiceInContainerNode);
ChoiceSchemaNode choiceSchemaNode = (ChoiceSchemaNode) choiceInContainerNode;
+ assertTrue(choiceSchemaNode.isMandatory());
ConstraintDefinition choiceConstraints = choiceSchemaNode.getConstraints();
- assertTrue(choiceConstraints.isMandatory());
assertTrue(choiceConstraints.getMustConstraints().isEmpty());
}
assertEquals(Optional.of("IP address of target node"), refineLeaf.getDescription());
assertEquals(Optional.of("address reference added by refine"), refineLeaf.getReference());
assertFalse(refineLeaf.isConfiguration());
- assertFalse(refineLeaf.getConstraints().isMandatory());
+ assertFalse(refineLeaf.isMandatory());
final Collection<MustDefinition> leafMustConstraints = refineLeaf.getConstraints().getMustConstraints();
assertEquals(1, leafMustConstraints.size());
final MustDefinition leafMust = leafMustConstraints.iterator().next();
assertEquals(Optional.of("address reference added by refine"), address_u.getReference());
assertFalse(address_u.isConfiguration());
assertTrue(address_u.isAddedByUses());
- assertFalse(address_u.getConstraints().isMandatory());
+ assertFalse(address_u.isMandatory());
final LeafSchemaNode address_g = (LeafSchemaNode) grouping.getDataChildByName(QName.create(
baz.getQNameModule(), "address"));
assertFalse(address_g.getReference().isPresent());
assertTrue(address_g.isConfiguration());
assertFalse(address_u.equals(address_g));
- assertTrue(address_g.getConstraints().isMandatory());
+ assertTrue(address_g.isMandatory());
assertEquals(address_g, SchemaNodeUtils.getRootOriginalIfPossible(address_u));
final ContainerSchemaNode port_u = (ContainerSchemaNode) destination.getDataChildByName(QName.create(
LeafSchemaNode leaf = (LeafSchemaNode) list.getDataChildByName(QName.create(testModule.getQNameModule(),
"key1"));
assertNotNull(leaf);
- assertTrue(leaf.getConstraints().isMandatory());
+ assertTrue(leaf.isMandatory());
assertEquals("int32", leaf.getType().getQName().getLocalName());
leaf = (LeafSchemaNode) list.getDataChildByName(QName.create(testModule.getQNameModule(), "key2"));
assertNotNull(leaf);
- assertTrue(leaf.getConstraints().isMandatory());
+ assertTrue(leaf.isMandatory());
assertEquals("int16", leaf.getType().getQName().getLocalName());
leaf = (LeafSchemaNode) list.getDataChildByName(QName.create(testModule.getQNameModule(), "old-leaf"));
assertNotNull(leaf);
- assertFalse(leaf.getConstraints().isMandatory());
+ assertFalse(leaf.isMandatory());
assertEquals("string", leaf.getType().getQName().getLocalName());
leaf = (LeafSchemaNode) list.getDataChildByName(QName.create(testModule.getQNameModule(), "young-leaf"));
assertNotNull(leaf);
- assertFalse(leaf.getConstraints().isMandatory());
+ assertFalse(leaf.isMandatory());
assertEquals("young-leaf", leaf.getType().getQName().getLocalName());
assertEquals(Optional.of("default-value"), leaf.getType().getDefaultValue());
final LeafListSchemaNode leafList = (LeafListSchemaNode) list.getDataChildByName(
QName.create(testModule.getQNameModule(), "list-of-leaves"));
assertNotNull(leafList);
- assertTrue(leafList.getConstraints().isMandatory());
assertTrue(leafList.isUserOrdered());
assertEquals(2, leafList.getConstraints().getMinElements().intValue());
assertEquals(20, leafList.getConstraints().getMaxElements().intValue());
// test DataSchemaNode args
assertFalse(data.isAugmenting());
assertFalse(data.isConfiguration());
+
+ assertTrue(data.isMandatory());
final ConstraintDefinition constraints = data.getConstraints();
assertEquals("class != 'wheel'", constraints.getWhenCondition().get().toString());
final Collection<MustDefinition> mustConstraints = constraints.getMustConstraints();
assertTrue(found1);
assertTrue(found2);
- assertTrue(constraints.isMandatory());
assertNull(constraints.getMinElements());
assertNull(constraints.getMaxElements());
}
assertTrue(found1);
assertTrue(found2);
- assertFalse(constraints.isMandatory());
assertNull(constraints.getMinElements());
assertNull(constraints.getMaxElements());
assertTrue(nodes.isPresenceContainer());
// ifEntry should be a context node ?
// assertNull(constraints.getWhenCondition());
assertEquals(0, constraints.getMustConstraints().size());
- assertTrue(constraints.isMandatory());
assertEquals(1, (int) constraints.getMinElements());
assertEquals(11, (int) constraints.getMaxElements());
// test AugmentationTarget args
assertEquals(Optional.of("description of address defined by refine"), refineLeaf.getDescription());
assertEquals(Optional.of("address reference added by refine"), refineLeaf.getReference());
assertFalse(refineLeaf.isConfiguration());
- assertTrue(refineLeaf.getConstraints().isMandatory());
+ assertTrue(refineLeaf.isMandatory());
final Collection<MustDefinition> leafMustConstraints = refineLeaf.getConstraints().getMustConstraints();
assertEquals(1, leafMustConstraints.size());
final MustDefinition leafMust = leafMustConstraints.iterator().next();
assertNotNull(choice);
assertEquals("configuration", choice.getQName().getLocalName());
- assertTrue(choice.getConstraints().isMandatory());
+ assertTrue(choice.isMandatory());
assertTrue(choice.isConfiguration());
assertEquals(1, choice.getCases().size());
assertNotNull(choice);
assertEquals("state", choice.getQName().getLocalName());
- assertFalse(choice.getConstraints().isMandatory());
+ assertFalse(choice.isMandatory());
assertFalse(choice.isConfiguration());
assertTrue(choice.getCases().isEmpty());
}
final LeafSchemaNode leaf1 = (LeafSchemaNode) grouping.getDataChildByName(QName.create(
testModule.getQNameModule(), "type"));
assertNotNull(leaf1);
- assertTrue(leaf1.getConstraints().isMandatory());
+ assertTrue(leaf1.isMandatory());
final LeafSchemaNode leaf2 = (LeafSchemaNode) grouping.getDataChildByName(QName.create(
testModule.getQNameModule(), "name"));
assertNotNull(leaf2);
- assertTrue(leaf2.getConstraints().isMandatory());
+ assertTrue(leaf2.isMandatory());
}
}
assertEquals("name", leaf.getQName().getLocalName());
assertEquals(Optional.of("Unique module instance name"), leaf.getDescription());
assertEquals(BaseTypes.stringType(), leaf.getType());
- assertTrue(leaf.getConstraints().isMandatory());
+ assertTrue(leaf.isMandatory());
leaf = (LeafSchemaNode) childrenIterator.next();
assertEquals("type", leaf.getQName().getLocalName());
assertTrue(leafType instanceof IdentityrefTypeDefinition);
assertEquals("module-type", ((IdentityrefTypeDefinition)leafType).getIdentities().iterator().next().getQName()
.getLocalName());
- assertTrue(leaf.getConstraints().isMandatory());
+ assertTrue(leaf.isMandatory());
}
}