*/
package org.opendaylight.yangtools.yang.model.api;
-import com.google.common.collect.ImmutableList;
import java.util.Collection;
import javax.annotation.Nonnull;
boolean isUserOrdered();
/**
- * All implementations should override this method.
- * The default definition of this method is used only in YANG 1.0 (RFC6020) implementation of
- * LeafListSchemaNode which does not support default statements.
- * YANG leaf-list statement has been changed in YANG 1.1 (RFC7950) and now allows default statements.
+ * Return the default value of this leaf-list, as per the rules outlined in
+ * <a href="https://tools.ietf.org/html/rfc7950#section-7.7.4">Section 7.4.4 of RFC7950</a>. RFC6020 does not
+ * allow for default value of leaf-list, hence the returned list will be empty.
*
- * @return collection of Strings which specify the default values of this leaf-list
+ * @return Ordered list of Strings which specify the default values of this leaf-list
*/
- // FIXME: version 2.0.0: make this method non-default
- @Nonnull default Collection<String> getDefaults() {
- return ImmutableList.of();
- }
+ @Nonnull Collection<? extends Object> getDefaults();
}
super.writer.endNode();
}
- private void emitDefaultNodes(final Collection<String> defaults) {
- for (final String defaultValue : defaults) {
+ private void emitDefaultNodes(final Collection<? extends Object> defaults) {
+ for (final Object defaultValue : defaults) {
emitDefaultNode(defaultValue);
}
}
}
}
+ // FIXME: We need to interpret the default value in terms of supplied element type
defaultValues = defaultValuesBuilder.build();
SourceException.throwIf(
TypeUtils.hasDefaultValueMarkedWithIfFeature(ctx.getRootVersion(), typeStmt, defaultValues),
"Leaf-list '%s' has one of its default values '%s' marked with an if-feature statement.",
ctx.getStatementArgument(), defaultValues);
+ // FIXME: RFC7950 section 7.7.4: we need to check for min-elements and defaultValues conflict
+
type = builder.build();
userOrdered = isUserOrdered;
}
assertTrue(findDataSchemaNode instanceof LeafListSchemaNode);
final LeafListSchemaNode myLeafList = (LeafListSchemaNode) findDataSchemaNode;
- final Collection<String> defaults = myLeafList.getDefaults();
+ final Collection<? extends Object> defaults = myLeafList.getDefaults();
assertEquals(2, defaults.size());
assertTrue(defaults.contains("my-default-value-1") && defaults.contains("my-default-value-2"));
}