Add collection under network for v13 and v14
[aai/aai-common.git] / aai-core / src / main / java / org / onap / aai / introspection / Version.java
1 /**
2  * ============LICENSE_START=======================================================
3  * org.onap.aai
4  * ================================================================================
5  * Copyright © 2017-2018 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 package org.onap.aai.introspection;
21
22 /**
23  * Requires the order to be in ascending order
24  */
25 public enum Version {
26         v8,
27         v9,
28         v10,
29         v11,
30         v12,
31         v13,
32         v14;
33
34         public static final String VERSION_EXPRESSION = "v8|v9|v10|v11|v12|v13|v14|latest";
35         public static final String VERSION_EXPRESSION_V8_PLUS = "v8|v9|v10|v11|v12|v13|v14|latest";
36         public static final String VERSION_EXPRESSION_V9_PLUS = "v9|v10|v11|v12|v13|v14|latest";
37
38         /**
39          * Checks if v is the latest version
40          * @param v
41          * @return
42          */
43         public static boolean isLatest(Version v) {
44                 return Version.getLatest().equals(v);
45         }
46
47         /**
48          * Gets the latest version
49          * @return
50          */
51         public static Version getLatest(){
52                 return Version.values()[Version.values().length-1];
53         }
54
55         /**
56          * To be used inplace of <b>Version.getVersion(String)</b> to correctly get version of "latest"
57          * @param v
58          * @return
59          */
60         public static Version getVersion(String v) {
61                 if ("latest".equals(v)) {
62                         return Version.getLatest();
63                 }
64                 return Version.valueOf(v);
65         }
66
67 }