Class BeanBuilder<T>

    • Constructor Detail

      • BeanBuilder

        public BeanBuilder​(BeanManager beanManager)
        Instantiate a new bean builder.
        Parameters:
        beanManager - the bean manager to use for creating injection targets and determining if annotations are qualifiers, scopes or stereotypes.
    • Method Detail

      • readFromType

        public BeanBuilder<T> readFromType​(AnnotatedType<T> type)

        Read the AnnotatedType, creating a bean from the class and it's annotations.

        By default the bean lifecycle will wrap the result of calling BeanManager#createInjectionTarget(AnnotatedType).

        BeanBuilder does not support reading members of the class to create producers or observer methods.

        Parameters:
        type - the type to read
      • create

        public Bean<T> create()

        Use the bean builder's current state to define the bean.

        Returns:
        the bean
      • getQualifiers

        public Set<Annotation> getQualifiers()
        Qualifiers currently defined for bean creation.
        Returns:
        the qualifiers current defined
      • qualifiers

        public BeanBuilder<T> qualifiers​(Set<Annotation> qualifiers)
        Define the qualifiers used for bean creation.
        Parameters:
        qualifiers - the qualifiers to use
      • qualifiers

        public BeanBuilder<T> qualifiers​(Annotation... qualifiers)
        Define the qualifiers used for bean creation.
        Parameters:
        qualifiers - the qualifiers to use
      • addQualifier

        public BeanBuilder<T> addQualifier​(Annotation qualifier)
        Add to the qualifiers used for bean creation.
        Parameters:
        qualifiers - the additional qualifier to use
      • addQualifiers

        public BeanBuilder<T> addQualifiers​(Annotation... qualifiers)
        Add to the qualifiers used for bean creation.
        Parameters:
        qualifiers - the additional qualifiers to use
      • addQualifiers

        public BeanBuilder<T> addQualifiers​(Collection<Annotation> qualifiers)
        Add to the qualifiers used for bean creation.
        Parameters:
        qualifiers - the additional qualifiers to use
      • getScope

        public Class<? extends Annotation> getScope()
        Scope currently defined for bean creation.
        Returns:
        the scope currently defined
      • scope

        public BeanBuilder<T> scope​(Class<? extends Annotation> scope)
        Define the scope used for bean creation.
        Parameters:
        scope - the scope to use
      • getStereotypes

        public Set<Class<? extends Annotation>> getStereotypes()
        Stereotypes currently defined for bean creation.
        Returns:
        the stereotypes currently defined
      • stereotypes

        public BeanBuilder<T> stereotypes​(Set<Class<? extends Annotation>> stereotypes)
        Define the stereotypes used for bean creation.
        Parameters:
        stereotypes - the stereotypes to use
      • getTypes

        public Set<Type> getTypes()
        Type closure currently defined for bean creation.
        Returns:
        the type closure currently defined
      • types

        public BeanBuilder<T> types​(Set<Type> types)
        Define the type closure used for bean creation.
        Parameters:
        types - the type closure to use
      • types

        public BeanBuilder<T> types​(Type... types)
        Define the type closure used for bean creation.
        Parameters:
        types - the type closure to use
      • addType

        public BeanBuilder<T> addType​(Type type)
        Add to the type closure used for bean creation.
        Parameters:
        type - additional type to use
      • addTypes

        public BeanBuilder<T> addTypes​(Type... types)
        Add to the type closure used for bean creation.
        Parameters:
        types - the additional types to use
      • addTypes

        public BeanBuilder<T> addTypes​(Collection<Type> types)
        Add to the type closure used for bean creation.
        Parameters:
        types - the additional types to use
      • isAlternative

        public boolean isAlternative()
        Whether the created bean will be an alternative.
        Returns:
        true if the created bean will be an alternative, otherwise false
      • alternative

        public BeanBuilder<T> alternative​(boolean alternative)
        Define that the created bean will (or will not) be an alternative.
        Parameters:
        alternative - true if the created bean should be an alternative, otherwise false
      • isNullable

        public boolean isNullable()
        Whether the created bean will be nullable.
        Returns:
        true if the created bean will be nullable, otherwise false
      • nullable

        public BeanBuilder<T> nullable​(boolean nullable)
        Define that the created bean will (or will not) be nullable.
        Parameters:
        nullable - true if the created bean should be nullable, otherwise false
      • getBeanClass

        public Class<?> getBeanClass()
        The bean class currently defined for bean creation.
        Returns:
        the bean class currently defined.
      • beanClass

        public BeanBuilder<T> beanClass​(Class<?> beanClass)
        Define the bean class used for bean creation.
        Parameters:
        beanClass - the bean class to use
      • getBeanManager

        public BeanManager getBeanManager()
        The bean manager in use. This cannot be changed for this BeanBuilder.
        Returns:
        the bean manager in use
      • getName

        public String getName()
        The name of the bean currently defined for bean creation.
        Returns:
        the name of the bean or null if the bean has no name
      • name

        public BeanBuilder<T> name​(String name)
        Define the name of the bean used for bean creation.
        Parameters:
        name - the name of the bean to use or null if the bean should have no name
      • isPassivationCapable

        public boolean isPassivationCapable()
        Whether the created bean will be passivation capable.
        Returns:
        true if the created bean will be passivation capable, otherwise false
      • passivationCapable

        public BeanBuilder<T> passivationCapable​(boolean passivationCapable)
        Define that the created bean will (or will not) be passivation capable.
        Parameters:
        nullable - true if the created bean should be passivation capable, otherwise false
      • getId

        public String getId()
        The id currently defined for bean creation.
        Returns:
        the id currently defined.
      • id

        public BeanBuilder<T> id​(String id)
        Define the id used for bean creation.
        Parameters:
        id - the id to use
      • getInjectionPoints

        public Set<InjectionPoint> getInjectionPoints()
        The injection points currently defined for bean creation.
        Returns:
        the injection points currently defined.
      • injectionPoints

        public BeanBuilder<T> injectionPoints​(Set<InjectionPoint> injectionPoints)
        Define the injection points used for bean creation.
        Parameters:
        injectionPoints - the injection points to use
      • getToString

        public String getToString()
        The string used when Object.toString() is called on the bean.
        Returns:
        the string currently defined