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.model.api;
10 import org.eclipse.jdt.annotation.NonNull;
11 import org.opendaylight.yangtools.concepts.Identifiable;
14 * The Type interface defines the base type for all types defined in java. Each
15 * Type defined in java MUST contain name and package name, except of primitive
16 * types like int, byte etc. In case of mapping of primitive type the package
17 * name MUST be left as empty string.
19 public interface Type extends Identifiable<JavaTypeName> {
21 * Returns name of the package that interface belongs to.
23 * @return name of the package that interface belongs to
25 default String getPackageName() {
26 return getIdentifier().packageName();
30 * Returns name of the interface.
32 * @return name of the interface.
34 default String getName() {
35 return getIdentifier().simpleName();
39 * Returns fully qualified name of Type. <br>
40 * The fully qualified name of Type MUST be returned in following format:
42 * <li>If does not contains package name: [type name] (e.g. int, byte,
44 * <li>If Type contains package name: [package name].[type name] (e.g
45 * java.lang.Byte, org.opendaylight.controller.gen.GenType)</li>
48 * @return fully qualified name of Type.
50 default String getFullyQualifiedName() {
51 return getIdentifier().toString();
54 static @NonNull Type of(final JavaTypeName identifier) {
55 return new DefaultType(identifier);
58 static @NonNull Type of(final Identifiable<JavaTypeName> type) {
59 return of(type.getIdentifier());
62 static @NonNull Type of(final Class<?> type) {
63 return of(JavaTypeName.create(type));