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

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

There is a newer version: 4.8.7
Show newest version
/*
 * Copyright 2017-2020 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.order.OrderUtil;
import io.micronaut.core.order.Ordered;
import io.micronaut.inject.BeanDefinition;
import io.micronaut.inject.BeanIdentifier;

import java.util.Objects;

/**
 * 

A bean registration is an association between a {@link BeanDefinition} and a created bean, typically a * {@link javax.inject.Singleton}.

* * @param The type * @author Graeme Rocher * @since 1.0 */ public class BeanRegistration implements Ordered { final BeanIdentifier identifier; final BeanDefinition beanDefinition; final T bean; /** * @param identifier The bean identifier * @param beanDefinition The bean definition * @param bean The bean instance */ public BeanRegistration(BeanIdentifier identifier, BeanDefinition beanDefinition, T bean) { this.identifier = identifier; this.beanDefinition = beanDefinition; this.bean = bean; } @Override public int getOrder() { return OrderUtil.getOrder(beanDefinition.getAnnotationMetadata(), bean); } /** * @return Teh bean identifier */ public BeanIdentifier getIdentifier() { return identifier; } /** * @return The bean definition */ public BeanDefinition getBeanDefinition() { return beanDefinition; } /** * @return The bean instance */ public T getBean() { return bean; } @Override public String toString() { return "BeanRegistration: " + bean; } @Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } BeanRegistration that = (BeanRegistration) o; return Objects.equals(identifier, that.identifier) && Objects.equals(beanDefinition, that.beanDefinition); } @Override public int hashCode() { return Objects.hash(identifier, beanDefinition); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy