Add plugin to check coverage
[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
33         public static final String VERSION_EXPRESSION = "v8|v9|v10|v11|v12|v13|latest";
34         public static final String VERSION_EXPRESSION_V8_PLUS = "v8|v9|v10|v11|v12|v13|latest";
35         public static final String VERSION_EXPRESSION_V9_PLUS = "v9|v10|v11|v12|v13|latest";
36
37         /**
38          * Checks if v is the latest version
39          * @param v
40          * @return
41          */
42         public static boolean isLatest(Version v) {
43                 return Version.getLatest().equals(v);
44         }
45
46         /**
47          * Gets the latest version
48          * @return
49          */
50         public static Version getLatest(){
51                 return Version.values()[Version.values().length-1];
52         }
53
54         /**
55          * To be used inplace of <b>Version.getVersion(String)</b> to correctly get version of "latest"
56          * @param v
57          * @return
58          */
59         public static Version getVersion(String v) {
60                 if ("latest".equals(v)) {
61                         return Version.getLatest();
62                 }
63                 return Version.valueOf(v);
64         }
65
66 }