2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.mdsal.binding.generator.spi;
10 import org.opendaylight.mdsal.binding.model.api.Restrictions;
11 import org.opendaylight.mdsal.binding.model.api.Type;
12 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
13 import org.opendaylight.yangtools.yang.model.api.SchemaNode;
14 import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
16 public interface TypeProvider {
18 * Resolve of YANG Type Definition to it's java counter part. If the Type Definition contains one of YANG primitive
19 * types the method will return {@code java.lang.} counterpart. (For example if YANG type is int32 the Java
20 * counterpart is {@link Integer}). In case that Type Definition contains extended type defined via YANG typedef
21 * statement the method SHOULD return Generated Type or Generated Transfer Object if that Type is correctly
22 * referenced to resolved imported YANG module.
25 * The method will return <code>null</code> value in situations that TypeDefinition can't be resolved (either due
26 * to missing YANG import or incorrectly specified type).
29 * {@code leafref} resolution for relative paths has two models of operation: lenient and strict. This is needed to
30 * handle the case where a grouping leaf's path points outside of the grouping tree. In such a case we cannot
31 * completely determine the correct type and need to fallback to {@link Object}.
33 * @param type Type Definition to resolve from
34 * @param lenientRelativeLeafrefs treat relative leafrefs leniently
35 * @return Resolved Type
37 Type javaTypeForSchemaDefinitionType(TypeDefinition<?> type, SchemaNode parentNode,
38 boolean lenientRelativeLeafrefs);
40 default Type javaTypeForSchemaDefinitionType(final TypeDefinition<?> type, final SchemaNode parentNode) {
41 return javaTypeForSchemaDefinitionType(type, parentNode, false);
44 Type javaTypeForSchemaDefinitionType(TypeDefinition<?> type, SchemaNode parentNode, Restrictions restrictions,
47 default Type javaTypeForSchemaDefinitionType(final TypeDefinition<?> type, final SchemaNode parentNode,
48 final Restrictions restrictions) {
49 return javaTypeForSchemaDefinitionType(type, parentNode, restrictions, false);
53 * Returns string containing code for creation of new type instance.
55 String getTypeDefaultConstruction(LeafSchemaNode node);
57 String getConstructorPropertyName(SchemaNode node);
59 String getParamNameFromType(TypeDefinition<?> type);