001/* 002 * Copyright 2017-2022 original authors 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * https://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package io.micronaut.maven.aot.internal; 017 018import java.util.Locale; 019import java.util.Optional; 020 021/** 022 * Packaging types supported by Micronaut's integrated AOT execution. 023 * 024 * @author Álvaro Sánchez-Mariscal 025 * @since 5.0.0 026 */ 027public enum AotPackaging { 028 JAR("jar"), 029 NATIVE_IMAGE("native-image"), 030 DOCKER("docker"), 031 DOCKER_NATIVE("docker-native"), 032 DOCKER_CRAC("docker-crac"), 033 K8S("k8s"), 034 OPENSHIFT("openshift"); 035 036 private final String id; 037 038 AotPackaging(String id) { 039 this.id = id; 040 } 041 042 public static AotPackaging of(String value) { 043 return AotPackaging.valueOf(value.replace("-", "_").toUpperCase(Locale.ROOT)); 044 } 045 046 public static Optional<AotPackaging> find(String value) { 047 try { 048 return Optional.of(of(value)); 049 } catch (IllegalArgumentException e) { 050 return Optional.empty(); 051 } 052 } 053 054 public String id() { 055 return id; 056 } 057}