File tree Expand file tree Collapse file tree 9 files changed +27
-27
lines changed
publish-subscribe/src/main/java/com/iluwatar/publish/subscribe Expand file tree Collapse file tree 9 files changed +27
-27
lines changed Original file line number Diff line number Diff line change 11package com .iluwatar .publish .subscribe .model ;
22
33/**
4- * This enum defines the content for {@link Topic} CUSTOMER_SUPPORT
4+ * This enum defines the content for {@link Topic} CUSTOMER_SUPPORT.
55 */
66public enum CustomerSupportContent {
77
Original file line number Diff line number Diff line change 11package com .iluwatar .publish .subscribe .model ;
22
33/**
4- * This class represents a Message that holds the published content
4+ * This class represents a Message that holds the published content.
55 */
66public record Message (Object content ) {
77}
Original file line number Diff line number Diff line change 55import java .util .concurrent .CopyOnWriteArraySet ;
66
77/**
8- * This class represents a Topic that topic name and subscribers
8+ * This class represents a Topic that topic name and subscribers.
99 */
1010public class Topic {
1111
@@ -22,7 +22,7 @@ public Topic(TopicName name) {
2222 }
2323
2424 /**
25- * Get the name of the topic
25+ * Get the name of the topic.
2626 *
2727 * @return topic name
2828 */
@@ -31,7 +31,7 @@ public TopicName getName() {
3131 }
3232
3333 /**
34- * Add a subscriber to the list of subscribers
34+ * Add a subscriber to the list of subscribers.
3535 *
3636 * @param subscriber subscriber to add
3737 */
@@ -40,7 +40,7 @@ public void addSubscriber(Subscriber subscriber) {
4040 }
4141
4242 /**
43- * Remove a subscriber to the list of subscribers
43+ * Remove a subscriber to the list of subscribers.
4444 *
4545 * @param subscriber subscriber to remove
4646 */
@@ -49,7 +49,7 @@ public void removeSubscriber(Subscriber subscriber) {
4949 }
5050
5151 /**
52- * Publish a message to subscribers
52+ * Publish a message to subscribers.
5353 *
5454 * @param message message with content to publish
5555 */
Original file line number Diff line number Diff line change 11package com .iluwatar .publish .subscribe .model ;
22
33/**
4- * This enum defines the available topic names to be used in {@link Topic}
4+ * This enum defines the available topic names to be used in {@link Topic}.
55 */
66public enum TopicName {
77 WEATHER ,
Original file line number Diff line number Diff line change 11package com .iluwatar .publish .subscribe .model ;
22
33/**
4- * This enum defines the content for {@link Topic} WEATHER
4+ * This enum defines the content for {@link Topic} WEATHER.
55 */
66public enum WeatherContent {
77 earthquake ("earthquake tsunami warning" ),
Original file line number Diff line number Diff line change 44import com .iluwatar .publish .subscribe .model .Topic ;
55
66/**
7- * This class represents a Publisher
7+ * This class represents a Publisher.
88 */
99public interface Publisher {
1010
11- /**
12- * Register a topic in the publisher
13- *
14- * @param topic the topic to be registered
15- */
16- void registerTopic (Topic topic );
11+ /**
12+ * Register a topic in the publisher.
13+ *
14+ * @param topic the topic to be registered
15+ */
16+ void registerTopic (Topic topic );
1717
18- /**
19- * Register a topic in the publisher
20- *
21- * @param topic the topic to publish the message under
22- * @param message message with content to be published
23- */
24- void publish (Topic topic , Message message );
18+ /**
19+ * Register a topic in the publisher.
20+ *
21+ * @param topic the topic to publish the message under
22+ * @param message message with content to be published
23+ */
24+ void publish (Topic topic , Message message );
2525}
Original file line number Diff line number Diff line change 88import org .slf4j .LoggerFactory ;
99
1010/**
11- * This class is an implementation of the Publisher
11+ * This class is an implementation of the Publisher.
1212 */
1313public class PublisherImpl implements Publisher {
1414
Original file line number Diff line number Diff line change 33import com .iluwatar .publish .subscribe .model .Message ;
44
55/**
6- * This class represents a Subscriber
6+ * This class represents a Subscriber.
77 */
88public interface Subscriber {
99
1010 /**
11- * On message method will trigger when the subscribed event is published
11+ * On message method will trigger when the subscribed event is published.
1212 *
1313 * @param message the message contains the content of the published event
1414 */
Original file line number Diff line number Diff line change 88import org .slf4j .LoggerFactory ;
99
1010/**
11- * This class subscribes to WEATHER topic
11+ * This class subscribes to WEATHER topic.
1212 */
1313@ Slf4j
1414public class WeatherSubscriber implements Subscriber {
You can’t perform that action at this time.
0 commit comments