Reformat catalog-model
[sdc.git] / catalog-model / src / main / java / org / openecomp / sdc / be / model / LifeCycleTransitionEnum.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 package org.openecomp.sdc.be.model;
21
22 public enum LifeCycleTransitionEnum {
23     // @formatter:off
24     CHECKOUT("checkout"),
25     CHECKIN("checkin"),
26     CERTIFICATION_REQUEST("certificationRequest"),
27     UNDO_CHECKOUT("undoCheckout"),
28     CANCEL_CERTIFICATION("cancelCertification"),
29     START_CERTIFICATION("startCertification"),
30     FAIL_CERTIFICATION("failCertification"),
31     CERTIFY("certify"),
32     DISTRIBUTE("distribute");
33     // @formatter:on
34
35     String displayName;
36
37     LifeCycleTransitionEnum(final String displayName) {
38         this.displayName = displayName;
39     }
40
41     public static LifeCycleTransitionEnum getFromDisplayName(final String name) {
42         if (name.equalsIgnoreCase(CHECKOUT.getDisplayName())) {
43             return CHECKOUT;
44         }
45         if (name.equalsIgnoreCase(CHECKIN.getDisplayName())) {
46             return CHECKIN;
47         }
48         if (name.equalsIgnoreCase(CERTIFICATION_REQUEST.getDisplayName())) {
49             return CERTIFICATION_REQUEST;
50         }
51         if (name.equalsIgnoreCase(UNDO_CHECKOUT.getDisplayName())) {
52             return UNDO_CHECKOUT;
53         }
54         if (name.equalsIgnoreCase(CANCEL_CERTIFICATION.getDisplayName())) {
55             return CANCEL_CERTIFICATION;
56         }
57         if (name.equalsIgnoreCase(START_CERTIFICATION.getDisplayName())) {
58             return START_CERTIFICATION;
59         }
60         if (name.equalsIgnoreCase(FAIL_CERTIFICATION.getDisplayName())) {
61             return FAIL_CERTIFICATION;
62         }
63         if (name.equalsIgnoreCase(CERTIFY.getDisplayName())) {
64             return CERTIFY;
65         }
66         if (name.equalsIgnoreCase(DISTRIBUTE.getDisplayName())) {
67             return DISTRIBUTE;
68         } else {
69             throw new IllegalArgumentException(name + " value does not match any of LifeCycleTransitionEnum values");
70         }
71     }
72
73     public static String valuesAsString() {
74         final StringBuilder sb = new StringBuilder();
75         for (final LifeCycleTransitionEnum op : LifeCycleTransitionEnum.values()) {
76             sb.append(op.getDisplayName()).append(" ");
77         }
78         return sb.toString();
79     }
80
81     public String getDisplayName() {
82         return displayName;
83     }
84 }