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.yang.types;
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.SchemaNode;
13 import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
15 public interface TypeProvider {
17 * Resolve of YANG Type Definition to it's java counter part. If the Type Definition contains one of YANG primitive
18 * types the method will return {@code java.lang.} counterpart. (For example if YANG type is int32 the Java
19 * counterpart is {@link Integer}). In case that Type Definition contains extended type defined via YANG typedef
20 * statement the method SHOULD return Generated Type or Generated Transfer Object if that Type is correctly
21 * referenced to resolved imported YANG module.
24 * The method will return <code>null</code> value in situations that TypeDefinition can't be resolved (either due
25 * to missing YANG import or incorrectly specified type).
28 * {@code leafref} resolution for relative paths has two models of operation: lenient and strict. This is needed to
29 * handle the case where a grouping leaf's path points outside of the grouping tree. In such a case we cannot
30 * completely determine the correct type and need to fallback to {@link Object}.
32 * @param type Type Definition to resolve from
33 * @param lenientRelativeLeafrefs treat relative leafrefs leniently
34 * @return Resolved Type
36 Type javaTypeForSchemaDefinitionType(TypeDefinition<?> type, SchemaNode parentNode,
37 boolean lenientRelativeLeafrefs);
39 default Type javaTypeForSchemaDefinitionType(final TypeDefinition<?> type, final SchemaNode parentNode) {
40 return javaTypeForSchemaDefinitionType(type, parentNode, false);
43 Type javaTypeForSchemaDefinitionType(TypeDefinition<?> type, SchemaNode parentNode, Restrictions restrictions,
46 default Type javaTypeForSchemaDefinitionType(final TypeDefinition<?> type, final SchemaNode parentNode,
47 final Restrictions restrictions) {
48 return javaTypeForSchemaDefinitionType(type, parentNode, restrictions, false);