1 /*
2 * Copyright 2006-2026 the original author or authors.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * https://www.apache.org/licenses/LICENSE-2.0
9 *
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.mybatis.generator.config;
17
18 import static org.mybatis.generator.internal.util.messages.Messages.getString;
19
20 import org.mybatis.generator.exception.InternalException;
21
22 /**
23 * Typesafe enum of different model types.
24 *
25 * @author Jeff Butler
26 */
27 public enum ModelType {
28 HIERARCHICAL("hierarchical"), //$NON-NLS-1$
29 FLAT("flat"), //$NON-NLS-1$
30 CONDITIONAL("conditional"), //$NON-NLS-1$
31 RECORD("record"); //$NON-NLS-1$
32
33 private final String type;
34
35 ModelType(String type) {
36 this.type = type;
37 }
38
39 public static ModelType getModelType(String type) {
40 if (HIERARCHICAL.type.equalsIgnoreCase(type)) {
41 return HIERARCHICAL;
42 } else if (FLAT.type.equalsIgnoreCase(type)) {
43 return FLAT;
44 } else if (CONDITIONAL.type.equalsIgnoreCase(type)) {
45 return CONDITIONAL;
46 } else if (RECORD.type.equalsIgnoreCase(type)) {
47 return RECORD;
48 } else {
49 throw new InternalException(getString("RuntimeError.13", type)); //$NON-NLS-1$
50 }
51 }
52 }