All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.quarkus.arc.runtime.SuppressConditions Maven / Gradle / Ivy

There is a newer version: 3.17.0.CR1
Show newest version
package io.quarkus.arc.runtime;

import java.util.Optional;

import org.eclipse.microprofile.config.Config;
import org.eclipse.microprofile.config.spi.ConfigProviderResolver;

public final class SuppressConditions {

    private SuppressConditions() {
    }

    public static boolean suppressIfProperty(String propertyName, String stringValue, boolean lookupIfMissing) {
        Config config = ConfigProviderResolver.instance().getConfig();
        Optional optionalValue = config.getOptionalValue(propertyName, String.class);
        if (optionalValue.isPresent()) {
            return !stringValue.equals(optionalValue.get());
        } else {
            return !lookupIfMissing;
        }
    }

    public static boolean suppressUnlessProperty(String propertyName, String stringValue, boolean lookupIfMissing) {
        Config config = ConfigProviderResolver.instance().getConfig();
        Optional optionalValue = config.getOptionalValue(propertyName, String.class);
        if (optionalValue.isPresent()) {
            return stringValue.equals(optionalValue.get());
        } else {
            return !lookupIfMissing;
        }
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy