Class BeanStream

  • All Implemented Interfaces:
    Iterable<BeanInfo>

    public final class BeanStream
    extends Object
    implements Iterable<BeanInfo>
    Convenient Stream wrapper that can be used to filter a set of beans.

    This object is stateful and cannot be reused. After a terminal opration is performed, the underlying stream is considered consumed, and can no longer be used.

    This construct is not threadsafe.

    • Method Detail

      • withScope

        public BeanStream withScope​(org.jboss.jandex.DotName scopeName)
        Parameters:
        scopeName -
        Returns:
        the new stream of beans
        See Also:
        BeanInfo.getScope()
      • withBeanType

        public BeanStream withBeanType​(org.jboss.jandex.DotName beanTypeName)
        Parameters:
        beanType -
        Returns:
        the new stream of beans
        See Also:
        BeanInfo.getTypes()
      • withBeanType

        public BeanStream withBeanType​(org.jboss.jandex.Type beanType)
        Parameters:
        beanType -
        Returns:
        the new stream of beans
        See Also:
        BeanInfo.getTypes()
      • matchBeanTypes

        public BeanStream matchBeanTypes​(Predicate<Set<org.jboss.jandex.Type>> predicate)
        Parameters:
        predicate -
        Returns:
        the new stream of beans
      • withBeanClass

        public BeanStream withBeanClass​(org.jboss.jandex.DotName beanClass)
        Parameters:
        beanClass -
        Returns:
        the new stream of beans
        See Also:
        BeanInfo.getBeanClass()
      • withQualifier

        public BeanStream withQualifier​(org.jboss.jandex.DotName... qualifierNames)
        Parameters:
        qualifierNames -
        Returns:
        the new stream of beans
        See Also:
        BeanInfo.getQualifiers()
      • withAroundInvokeInterceptor

        public BeanStream withAroundInvokeInterceptor()
        Returns:
        the new stream of beans that have an associated interceptor
      • withLifecycleInterceptor

        public BeanStream withLifecycleInterceptor()
        Returns:
        the new stream of beans that have an associated lifecycle interceptor
      • producers

        public BeanStream producers()
        Returns:
        the new stream of producer beans
      • producerMethods

        public BeanStream producerMethods()
        Returns:
        the new stream of producer method beans
      • producerFields

        public BeanStream producerFields()
        Returns:
        the new stream of producer field beans
      • classBeans

        public BeanStream classBeans()
        Returns:
        the new stream of class beans
      • syntheticBeans

        public BeanStream syntheticBeans()
        Returns:
        the new stream of synthetic beans
      • assignableTo

        public BeanStream assignableTo​(org.jboss.jandex.Type requiredType,
                                       org.jboss.jandex.AnnotationInstance... requiredQualifiers)
        Parameters:
        requiredType -
        requiredQualifiers -
        Returns:
        the new stream of beans assignable to the required type and qualifiers
      • collect

        public List<BeanInfo> collect()
        Terminal operation.
        Returns:
        the list of beans
      • stream

        public Stream<BeanInfo> stream()
        Returns:
        the underlying stream instance
      • isEmpty

        public boolean isEmpty()
        Terminal operation.
        Returns:
        true if the stream contains no elements
      • firstResult

        public Optional<BeanInfo> firstResult()
        Terminal operation.
        Returns:
        an Optional with the first matching bean, or an empty Optional if no bean is matching
      • collect

        public <R,​A> R collect​(Collector<BeanInfo,​A,​R> collector)
        Terminal operation.
        Type Parameters:
        R -
        A -
        Parameters:
        collector -
        Returns:
        the collected result