|
| 1 | +/* |
| 2 | + * Licensed to the Apache Software Foundation (ASF) under one or more |
| 3 | + * contributor license agreements. See the NOTICE file distributed with |
| 4 | + * this work for additional information regarding copyright ownership. |
| 5 | + * The ASF licenses this file to You under the Apache License, Version 2.0 |
| 6 | + * (the "License"); you may not use this file except in compliance with |
| 7 | + * the License. You may obtain a copy of the License at |
| 8 | + * |
| 9 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | + * |
| 11 | + * Unless required by applicable law or agreed to in writing, software |
| 12 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | + * See the License for the specific language governing permissions and |
| 15 | + * limitations under the License. |
| 16 | + */ |
| 17 | + |
| 18 | +package org.apache.inlong.manager.common.enums; |
| 19 | + |
| 20 | +import org.apache.inlong.manager.common.util.Preconditions; |
| 21 | + |
| 22 | +import java.util.Locale; |
| 23 | + |
| 24 | +/** |
| 25 | + * Iceberg partition type |
| 26 | + */ |
| 27 | +public enum IcebergPartition { |
| 28 | + IDENTITY, |
| 29 | + BUCKET, |
| 30 | + TRUNCATE, |
| 31 | + YEAR, |
| 32 | + MONTH, |
| 33 | + DAY, |
| 34 | + HOUR, |
| 35 | + ; |
| 36 | + |
| 37 | + /** |
| 38 | + * Get partition type from name |
| 39 | + */ |
| 40 | + public static IcebergPartition forName(String name) { |
| 41 | + Preconditions.checkNotNull(name, "IcebergPartition should not be null"); |
| 42 | + for (IcebergPartition value : values()) { |
| 43 | + if (value.toString().equals(name) || value.toString().equals(name.toUpperCase(Locale.ROOT))) { |
| 44 | + return value; |
| 45 | + } |
| 46 | + } |
| 47 | + throw new IllegalArgumentException(String.format("Unsupported IcebergPartition : %s", name)); |
| 48 | + } |
| 49 | + |
| 50 | + @Override |
| 51 | + public String toString() { |
| 52 | + return name(); |
| 53 | + } |
| 54 | +} |
0 commit comments