e33d63f4c4335b27d1ce274c1f5024f345692802
[mdsal.git] / binding2 / mdsal-binding2-generator-api / src / main / java / org / opendaylight / mdsal / binding / javav2 / generator / spi / TypeProvider.java
1 /*
2  * Copyright (c) 2017 Cisco Systems, Inc. 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
9 package org.opendaylight.mdsal.binding.javav2.generator.spi;
10
11 import com.google.common.annotations.Beta;
12 import org.opendaylight.mdsal.binding.javav2.model.api.Restrictions;
13 import org.opendaylight.mdsal.binding.javav2.model.api.Type;
14 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
15 import org.opendaylight.yangtools.yang.model.api.SchemaNode;
16 import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
17
18 /**
19  * Service provider interface that defines contract for generated types.
20  */
21 @Beta
22 public interface TypeProvider {
23
24     /**
25      * Resolve of yang Type Definition to its java counter part.
26      * If the Type Definition contains one of yang primitive types the method
27      * will return java.lang. counterpart. (For example if yang type is int32
28      * the java counterpart is java.lang.Integer). In case that Type
29      * Definition contains extended type defined via yang typedef statement
30      * the method SHOULD return Generated Type or Generated Transfer Object
31      * if that Type is correctly referenced to resolved imported yang module.
32      * The method will return <code>null</code> value in situations that
33      * TypeDefinition can't be resolved (either due missing yang import or
34      * incorrectly specified type).
35      *
36      *
37      * @param type Type Definition to resolve from
38      * @param parentNode parent node
39      * @return Resolved Type
40      */
41     Type javaTypeForSchemaDefinitionType(TypeDefinition<?> type, SchemaNode parentNode);
42
43     /**
44      *
45      * @param type Type Definition to resolve from
46      * @param parentNode parent node
47      * @param restrictions restrictions applied to given type definition
48      * @return Resolved Type
49      */
50     Type javaTypeForSchemaDefinitionType(TypeDefinition<?> type, SchemaNode parentNode, Restrictions restrictions);
51
52     /**
53      * Returns string containing code for creation of new type instance.
54      *
55      * @param node Schema node to resolve from
56      * @return String representing default construction
57      */
58     String getTypeDefaultConstruction(LeafSchemaNode node);
59
60     /**
61      *
62      * @param node Schema node to resolve from
63      * @return String representing constructor property name
64      */
65     String getConstructorPropertyName(SchemaNode node);
66
67     /**
68      *
69      * @param type Type Definition to resolve from
70      * @return String representing parameter name
71      */
72     String getParamNameFromType(TypeDefinition<?> type);
73
74 }