Bump to odlparent-9.0.0/yangtools-7.0.1-SNAPSHOT
[mdsal.git] / binding / mdsal-binding-generator-impl / src / main / java / org / opendaylight / mdsal / binding / generator / impl / reactor / LeafListGenerator.java
1 /*
2  * Copyright (c) 2021 PANTHEON.tech, s.r.o. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.mdsal.binding.generator.impl.reactor;
9
10 import org.opendaylight.mdsal.binding.model.api.Type;
11 import org.opendaylight.mdsal.binding.model.util.Types;
12 import org.opendaylight.yangtools.yang.model.api.stmt.LeafListEffectiveStatement;
13
14 /**
15  * Generator corresponding to a {@code leaf-list} statement.
16  */
17 final class LeafListGenerator extends AbstractTypeAwareGenerator<LeafListEffectiveStatement> {
18     LeafListGenerator(final LeafListEffectiveStatement statement, final AbstractCompositeGenerator<?> parent) {
19         super(statement, parent);
20     }
21
22     @Override
23     Type methodReturnType(final TypeBuilderFactory builderFactory) {
24         // If we are a leafref and the reference cannot be resolved, we need to generate a list wildcard, not
25         // List<Object>, we will try to narrow the return type in subclasses.
26         final Type type = super.methodReturnType(builderFactory);
27         return Types.objectType().equals(type) ? Types.listTypeWildcard() : Types.listTypeFor(type);
28     }
29 }