package org.opendaylight.yangtools.yang.model.api.type;
import java.util.List;
-
import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
/**
* 4</a>). <br>
* The canonical form of a binary value follows the rules in <a
* href="https://tools.ietf.org/html/rfc4648">[RFC4648]</a>.
- *
+ *
* <br>
* <br>
* This interface was modeled according to definition in <a
* href="https://tools.ietf.org/html/rfc6020#section-9.8">[RFC-6020] The binary
* Built-In Type</a>
- *
*/
public interface BinaryTypeDefinition extends TypeDefinition<BinaryTypeDefinition> {
/**
- * Returns List of number of octets that binary value contains.
- *
+ * Returns List of number of octets that binary value contains. These are the effective constraints, e.g. they include
+ * any range constraints imposed by base types.
+ *
* @return List of number of octets that binary value contains.
- *
+ *
* @see LengthConstraint
*/
List<LengthConstraint> getLengthConstraints();
package org.opendaylight.yangtools.yang.model.api.type;
import java.util.List;
-
import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
/**
- *
+ *
* Contains method for getting data from the <code>string</code> YANG built-in
* type.
*/
public interface StringTypeDefinition extends TypeDefinition<StringTypeDefinition> {
/**
- * Returns length constraint specified in the string.
- *
+ * Returns length constraint specified in the string. These are the effective constraints, e.g. they include
+ * any length constraints implied by base types.
+ *
* @return list of length constraint which are specified in the
- * <code>lenght</code> substatement of the <code>type</code>
+ * <code>length</code> substatement of the <code>type</code>
* statement
*/
List<LengthConstraint> getLengthConstraints();
/**
* Returns patterns specified in the string.
- *
+ *
* @return list of pattern constraints which are specified in the
* <code>pattern</code> substatement of the <code>type</code>
* statement
@Override
final T buildType() {
+ final List<LengthConstraint> baseLengths = findLenghts();
+
if (lengthAlternatives == null || lengthAlternatives.isEmpty()) {
- return buildType(ImmutableList.<LengthConstraint>of());
+ return buildType(baseLengths);
}
- final List<LengthConstraint> baseLengths = findLenghts();
-
// Run through alternatives and resolve them against the base type
final List<LengthConstraint> resolvedLengths = ensureResolvedLengths(lengthAlternatives, baseLengths);
assertEquals(1, patterns.size());
PatternConstraint pattern = patterns.iterator().next();
assertEquals("^[e-z]*$", pattern.getRegularExpression());
- assertTrue(type.getLengthConstraints().isEmpty());
+ assertEquals(1, type.getLengthConstraints().size());
StringTypeDefinition baseType1 = type.getBaseType();
QName baseType1QName = baseType1.getQName();
assertEquals(1, patterns.size());
pattern = patterns.iterator().next();
assertEquals("^[b-u]*$", pattern.getRegularExpression());
- assertTrue(baseType1.getLengthConstraints().isEmpty());
+ assertEquals(1, baseType1.getLengthConstraints().size());
StringTypeDefinition baseType2 = baseType1.getBaseType();
QName baseType2QName = baseType2.getQName();
assertEquals(1, patterns.size());
PatternConstraint pattern = patterns.iterator().next();
assertEquals("^[e-z]*$", pattern.getRegularExpression());
- assertTrue(type.getLengthConstraints().isEmpty());
+ assertEquals(1, type.getLengthConstraints().size());
final LeafSchemaNode multiplePatternDirectStringDefLeaf = (LeafSchemaNode) foo
.getDataChildByName("multiple-pattern-direct-string-def-leaf");