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