01: /*
02: * Copyright 2008 Outerthought bvba and Schaubroeck nv
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16: package org.outerj.daisy.repository;
17:
18: /**
19: * Indicates if a {@link Version} contains major or minor changes.
20: *
21: * <p>See {@link Version#setChangeType} for more details on intended usage.
22: */
23: public enum ChangeType {
24: MAJOR("major", "M"), MINOR("minor", "N");
25:
26: private final String name;
27: private final String code;
28:
29: private ChangeType(String name, String code) {
30: this .name = name;
31: this .code = code;
32: }
33:
34: public String toString() {
35: return name;
36: }
37:
38: public String getCode() {
39: return code;
40: }
41:
42: public static ChangeType getByCode(String code) {
43: if (code.equals("M")) {
44: return ChangeType.MAJOR;
45: } else if (code.equals("N")) {
46: return ChangeType.MINOR;
47: } else {
48: throw new RuntimeException("Invalid ChangeType code: "
49: + code);
50: }
51: }
52:
53: public static ChangeType fromString(String name) {
54: if (name.equals("major"))
55: return ChangeType.MAJOR;
56: else if (name.equals("minor"))
57: return ChangeType.MINOR;
58: else
59: throw new RuntimeException("Invalid ChangeType name: "
60: + name);
61: }
62:
63: }
|