Integrate JavaTypeName as Identifier
[mdsal.git] / binding / mdsal-binding-generator-api / src / main / java / org / opendaylight / mdsal / binding / model / api / Type.java
1 /*
2  * Copyright (c) 2013 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 package org.opendaylight.mdsal.binding.model.api;
9
10 import org.opendaylight.yangtools.concepts.Identifiable;
11
12 /**
13  * The Type interface defines the base type for all types defined in java. Each
14  * Type defined in java MUST contain name and package name, except of primitive
15  * types like int, byte etc. In case of mapping of primitive type the package
16  * name MUST be left as empty string.
17  */
18 public interface Type extends Identifiable<JavaTypeName> {
19     /**
20      * Returns name of the package that interface belongs to.
21      *
22      * @return name of the package that interface belongs to
23      */
24     default String getPackageName() {
25         return getIdentifier().packageName();
26     }
27
28     /**
29      * Returns name of the interface.
30      *
31      * @return name of the interface.
32      */
33     default String getName() {
34         return getIdentifier().simpleName();
35     }
36
37     /**
38      * Returns fully qualified name of Type. <br>
39      * The fully qualified name of Type MUST be returned in following format:
40      * <ul>
41      * <li>If does not contains package name: [type name] (e.g. int, byte,
42      * byte[],...)</li>
43      * <li>If Type contains package name: [package name].[type name] (e.g
44      * java.lang.Byte, org.opendaylight.controller.gen.GenType)</li>
45      * </ul>
46      *
47      * @return fully qualified name of Type.
48      */
49     default String getFullyQualifiedName() {
50         return getIdentifier().toString();
51     }
52 }