Extend BindingNamespaceType
[mdsal.git] / binding2 / mdsal-binding2-spec / src / main / java / org / opendaylight / mdsal / binding / javav2 / spec / runtime / BindingNamespaceType.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.spec.runtime;
10
11 import com.google.common.annotations.Beta;
12 import com.google.common.base.Preconditions;
13
14 /**
15  * Binding Namespace is structure of Java packages designed to prevent conflicts in YANG Java
16  * Binding, since Java does have only one namespace.
17  */
18 @Beta
19 public enum BindingNamespaceType {
20
21     /**
22      *
23      * Namespace containing all derived types, defined from grouping and data namespaces
24      *
25      */
26     Typedef("type"), Identity("ident"), Key("key"), Data("data"), Notification("data"), Operation("data"),
27     Grouping("grp"), Builder("dto");
28
29     private final String packagePrefix;
30
31     BindingNamespaceType(String packagePrefix) {
32         this.packagePrefix = Preconditions.checkNotNull(packagePrefix);
33     }
34
35     public String getPackagePrefix() {
36         return packagePrefix;
37     }
38
39     public static Boolean isData(final BindingNamespaceType type) {
40         return isTreeData(type) || isNotificationData(type) || isOperationData(type);
41     }
42
43     public static Boolean isTreeData(final BindingNamespaceType type) {
44         return Data.equals(type);
45     }
46
47     public static Boolean isNotificationData(final BindingNamespaceType type) {
48         return Notification.equals(type);
49     }
50
51     public static Boolean isOperationData(final BindingNamespaceType type) {
52         return Operation.equals(type);
53     }
54
55     public static Boolean isGrouping(final BindingNamespaceType type) {
56         return Grouping.equals(type);
57     }
58 }