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

io.micronaut.context.DisabledBean Maven / Gradle / Ivy

/*
 * Copyright 2017-2022 original authors
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package io.micronaut.context;

import io.micronaut.core.annotation.NonNull;
import io.micronaut.core.annotation.Nullable;
import io.micronaut.core.type.Argument;
import io.micronaut.inject.BeanDefinition;
import io.micronaut.inject.BeanDefinitionReference;

import java.util.List;

/**
 * Data about a disabled bean. Used to improve error reporting.
 *
 * @param type The bean type
 * @param qualifier The qualifier
 * @param reasons The reasons the bean is disabled
 * @param  The bean type
 */
public record DisabledBean(
    @NonNull Argument type,
    @Nullable Qualifier qualifier,
    @NonNull List reasons)
    implements BeanDefinition, BeanDefinitionReference {

    @Override
    public boolean isEnabled(BeanContext context, BeanResolutionContext resolutionContext) {
        return true;
    }

    @Override
    public boolean isConfigurationProperties() {
        return BeanDefinition.super.isConfigurationProperties();
    }

    @Override
    public boolean isSingleton() {
        return BeanDefinition.super.isSingleton();
    }

    @Override
    public Qualifier getDeclaredQualifier() {
        return qualifier;
    }

    @Override
    public Class getBeanType() {
        return type.getType();
    }

    @Override
    public Argument asArgument() {
        return type;
    }

    @Override
    public Argument getGenericBeanType() {
        return type;
    }

    @Override
    public String getBeanDefinitionName() {
        return type.getTypeName();
    }

    @Override
    public BeanDefinition load() {
        return this;
    }

    @Override
    public boolean isPresent() {
        return true;
    }

    @Override
    public int hashCode() {
        return type.typeHashCode();
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy