push addional code
[sdc.git] / openecomp-be / lib / openecomp-tosca-lib / src / main / java / org / openecomp / sdc / tosca / datatypes / ToscaNodeType.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.openecomp.sdc.tosca.datatypes;
22
23 import org.openecomp.sdc.tosca.services.ToscaConstants;
24
25 import java.util.Collections;
26 import java.util.HashMap;
27 import java.util.Map;
28
29
30 /**
31  * The enum Tosca node type.
32  */
33 public enum ToscaNodeType {
34
35   /**
36    * Compute tosca node type.
37    */
38   COMPUTE("tosca.nodes.Compute"),
39   /**
40    * Root tosca node type.
41    */
42   ROOT("tosca.nodes.Root"),
43   /**
44    * Block storage tosca node type.
45    */
46   BLOCK_STORAGE("tosca.nodes.BlockStorage"),
47   /**
48    * Network tosca node type.
49    */
50   NETWORK("tosca.nodes.network.Network"),
51   /**
52    * Network port tosca node type.
53    */
54   NETWORK_PORT("tosca.nodes.network.Port"),
55   /**
56    * Nova server tosca node type.
57    */
58   NOVA_SERVER(ToscaConstants.NODES_PREFIX + "nova.Server"),
59   /**
60    * Cinder volume tosca node type.
61    */
62   CINDER_VOLUME(ToscaConstants.NODES_PREFIX + "cinder.Volume"),
63   /**
64    * Neutron net tosca node type.
65    */
66   NEUTRON_NET("org.openecomp.resource.vl.nodes.heat.network.neutron.Net"),
67   /**
68    * Neutron port tosca node type.
69    */
70   NEUTRON_PORT("org.openecomp.resource.cp.nodes.heat.network.neutron.Port"),
71   /**
72    * Neutron security rules tosca node type.
73    */
74   NEUTRON_SECURITY_RULES("org.openecomp.resource.vfc.rules.nodes"
75       + ".heat.network.neutron.SecurityRules"),
76   /**
77    * Contrail virtual network tosca node type.
78    */
79   CONTRAIL_VIRTUAL_NETWORK("org.openecomp.resource.vl.nodes.heat.network.contrail.VirtualNetwork"),
80   /**
81    * Contrail network rule tosca node type.
82    */
83   CONTRAIL_NETWORK_RULE("org.openecomp.resource.vfc."
84       + "rules.nodes.heat.network.contrail.NetworkRules"),
85   /**
86    * Contrailv 2 virtual network tosca node type.
87    */
88   CONTRAILV2_VIRTUAL_NETWORK("org.openecomp.resource.vl.nodes."
89       + "heat.network.contrailV2.VirtualNetwork"),
90   /**
91    * Contrailv 2 network rule tosca node type.
92    */
93   CONTRAILV2_NETWORK_RULE(
94       "org.openecomp.resource.vfc.rules.nodes.heat.network.contrailV2.NetworkRules"),
95   /**
96    * Contrailv 2 virtual machine interface tosca node type.
97    */
98   CONTRAILV2_VIRTUAL_MACHINE_INTERFACE(
99       "org.openecomp.resource.cp.nodes.heat.contrailV2.VirtualMachineInterface"),
100   /**
101    * Abstract substitute tosca node type.
102    */
103   ABSTRACT_SUBSTITUTE("org.openecomp.resource.abstract.nodes.AbstractSubstitute"),
104   /**
105    * Contrail compute tosca node type.
106    */
107   CONTRAIL_COMPUTE(ToscaConstants.NODES_PREFIX + "contrail.Compute"),
108   /**
109    * Contrail port tosca node type.
110    */
111   CONTRAIL_PORT("org.openecomp.resource.cp.nodes.heat.network.contrail.Port"),
112   /**
113    * Contrail abstract substitute tosca node type.
114    */
115   CONTRAIL_ABSTRACT_SUBSTITUTE("org.openecomp.resource.abstract."
116       + "nodes.contrail.AbstractSubstitute"),;
117
118   private static final Map<String, ToscaNodeType> mMap =
119       Collections.unmodifiableMap(initializeMapping());
120   private String displayName;
121
122   ToscaNodeType(String displayName) {
123     this.displayName = displayName;
124   }
125
126   /**
127    * Initialize mapping map.
128    *
129    * @return the map
130    */
131   public static Map<String, ToscaNodeType> initializeMapping() {
132     Map<String, ToscaNodeType> toscaMap = new HashMap<>();
133     for (ToscaNodeType v : ToscaNodeType.values()) {
134       toscaMap.put(v.displayName, v);
135     }
136     return toscaMap;
137   }
138
139   /**
140    * Gets tosca node type by display name.
141    *
142    * @param displayName the display name
143    * @return the tosca node type by display name
144    */
145   public static ToscaNodeType getToscaNodeTypeByDisplayName(String displayName) {
146     if (mMap.containsKey(displayName)) {
147       return mMap.get(displayName);
148     }
149     return null;
150   }
151
152   /**
153    * Gets display name.
154    *
155    * @return the display name
156    */
157   public String getDisplayName() {
158     return displayName;
159   }
160
161
162 }