Class TopicImpl<T>

  • All Implemented Interfaces:
    Topic<T>

    public class TopicImpl<T>
    extends java.lang.Object
    implements Topic<T>
    • Constructor Summary

      Constructors 
      Constructor Description
      TopicImpl​(ServiceLocatorImpl locator, java.lang.reflect.Type topicType, java.util.Set<java.lang.annotation.Annotation> requiredQualifiers)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.util.Set<java.lang.annotation.Annotation> getTopicQualifiers()
      The qualifiers associated with this Topic.
      java.lang.reflect.Type getTopicType()
      Gets the type of the topic, in order to match the message to subscribers
      Topic<T> named​(java.lang.String name)
      Returns an Topic that is further qualified with the given name
      <U> Topic<U> ofType​(java.lang.reflect.Type type)
      Returns an Topic that is of the given type.
      void publish​(T message)
      Publishes a message to all subscribers
      Topic<T> qualifiedWith​(java.lang.annotation.Annotation... qualifiers)
      A set of qualifiers to further restrict this Topic to.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • topicType

        private final java.lang.reflect.Type topicType
      • requiredQualifiers

        private final java.util.Set<java.lang.annotation.Annotation> requiredQualifiers
    • Constructor Detail

      • TopicImpl

        TopicImpl​(ServiceLocatorImpl locator,
                  java.lang.reflect.Type topicType,
                  java.util.Set<java.lang.annotation.Annotation> requiredQualifiers)
    • Method Detail

      • publish

        public void publish​(T message)
        Description copied from interface: Topic
        Publishes a message to all subscribers
        Specified by:
        publish in interface Topic<T>
        Parameters:
        message - The non-null message to send to all current subscribers
      • named

        public Topic<T> named​(java.lang.String name)
        Description copied from interface: Topic
        Returns an Topic that is further qualified with the given name
        Specified by:
        named in interface Topic<T>
        Parameters:
        name - The value field of the Named annotation parameter. Must not be null
        Returns:
        A topic further qualified with the given name
      • ofType

        public <U> Topic<U> ofType​(java.lang.reflect.Type type)
        Description copied from interface: Topic
        Returns an Topic that is of the given type. This type must be more specific than the type of this Topic
        Specified by:
        ofType in interface Topic<T>
        Parameters:
        type - The type to restrict the returned Topic to
        Returns:
        A Topic restricted to only producing messages of the given type
      • qualifiedWith

        public Topic<T> qualifiedWith​(java.lang.annotation.Annotation... qualifiers)
        Description copied from interface: Topic
        A set of qualifiers to further restrict this Topic to.
        Specified by:
        qualifiedWith in interface Topic<T>
        Parameters:
        qualifiers - The qualifiers to further restrict this Topic to
        Returns:
        An Topic restricted with the given qualifiers
      • getTopicType

        public java.lang.reflect.Type getTopicType()
        Description copied from interface: Topic
        Gets the type of the topic, in order to match the message to subscribers
        Specified by:
        getTopicType in interface Topic<T>
        Returns:
        the Type of this topic. Will not return null
      • getTopicQualifiers

        public java.util.Set<java.lang.annotation.Annotation> getTopicQualifiers()
        Description copied from interface: Topic
        The qualifiers associated with this Topic. Messages should only be distributed to subscribers that have matching qualifiers
        Specified by:
        getTopicQualifiers in interface Topic<T>
        Returns:
        the non-null but possibly empty set of qualifiers associated with this Topic