*/
package org.opendaylight.mdsal.binding.generator.impl.reactor;
+import org.opendaylight.mdsal.binding.generator.impl.rt.DefaultLeafListRuntimeType;
import org.opendaylight.mdsal.binding.model.api.Type;
import org.opendaylight.mdsal.binding.model.ri.Types;
+import org.opendaylight.mdsal.binding.runtime.api.LeafListRuntimeType;
+import org.opendaylight.yangtools.yang.common.Ordering;
import org.opendaylight.yangtools.yang.model.api.stmt.LeafListEffectiveStatement;
/**
* Generator corresponding to a {@code leaf-list} statement.
*/
-final class LeafListGenerator extends AbstractTypeAwareGenerator<LeafListEffectiveStatement> {
- LeafListGenerator(final LeafListEffectiveStatement statement, final AbstractCompositeGenerator<?> parent) {
+final class LeafListGenerator
+ extends AbstractTypeAwareGenerator<LeafListEffectiveStatement, LeafListRuntimeType, LeafListGenerator> {
+ LeafListGenerator(final LeafListEffectiveStatement statement, final AbstractCompositeGenerator<?, ?> parent) {
super(statement, parent);
}
// If we are a leafref and the reference cannot be resolved, we need to generate a list wildcard, not
// List<Object>, we will try to narrow the return type in subclasses.
final Type type = super.methodReturnType(builderFactory);
- return Types.objectType().equals(type) ? Types.listTypeWildcard() : Types.listTypeFor(type);
+ final boolean isObject = Types.objectType().equals(type);
+
+ if (statement().ordering() == Ordering.SYSTEM) {
+ return isObject ? Types.setTypeWildcard() : Types.setTypeFor(type);
+ }
+ return isObject ? Types.listTypeWildcard() : Types.listTypeFor(type);
+ }
+
+ @Override
+ LeafListRuntimeType createExternalRuntimeType(final Type type) {
+ return new DefaultLeafListRuntimeType(type, statement());
+ }
+
+ @Override
+ LeafListRuntimeType createInternalRuntimeType(final ChildLookup lookup, final LeafListEffectiveStatement statement,
+ final Type type) {
+ return new DefaultLeafListRuntimeType(type, statement);
}
}