001/*
002 * Copyright 2017-2026 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.jdkaotcache;
017
018import io.micronaut.core.annotation.Internal;
019
020import java.util.Locale;
021
022/**
023 * The values of {@code micronaut.docker.jdkAotCache.trainingMode}: how far the application goes in the JDK AOT cache
024 * training run.
025 *
026 * @author Álvaro Sánchez-Mariscal
027 * @since 5.1.0
028 */
029@Internal
030public enum TrainingMode {
031
032    /**
033     * The application loads its bean definitions and the classes they name, creates no bean and exits. It does not
034     * start, so the training needs none of the services that its beans use.
035     */
036    LOAD,
037
038    /**
039     * The application starts, answers the training requests and is stopped.
040     */
041    START;
042
043    /**
044     * The plugin parameter that selects the mode.
045     */
046    static final String PARAMETER = "micronaut.docker.jdkAotCache.trainingMode";
047
048    /**
049     * @return the value of the mode in the Micronaut property {@value TrainingRunSwitch#MODE_PROPERTY}
050     */
051    String id() {
052        return name().toLowerCase(Locale.ROOT);
053    }
054
055    /**
056     * @return the plugin parameter set to this mode, for messages
057     */
058    String option() {
059        return PARAMETER + "=" + name();
060    }
061}