Skip to content

Commit 6207a4f

Browse files
committed
Polishing.
Replace topic label with assertion message. Reorder methods to align with Spring style. See #2662 Original pull request: #2663
1 parent 979fb6a commit 6207a4f

File tree

4 files changed

+190
-204
lines changed

4 files changed

+190
-204
lines changed

src/main/java/org/springframework/data/redis/listener/AbstractTopic.java

+3-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2017-2023 the original author or authors.
2+
* Copyright 2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -16,22 +16,19 @@
1616
package org.springframework.data.redis.listener;
1717

1818
import org.springframework.lang.Nullable;
19-
import org.springframework.util.Assert;
2019
import org.springframework.util.ObjectUtils;
2120

2221
/**
2322
* Abstract base class for defining {@link Topic Topics}.
2423
*
2524
* @author John Blum
26-
* @see org.springframework.data.redis.listener.Topic
27-
* @since 3.2.0
25+
* @since 3.1.3
2826
*/
2927
abstract class AbstractTopic implements Topic {
3028

3129
private final String name;
3230

33-
AbstractTopic(String label, String name) {
34-
Assert.notNull(name,() -> label + " must not be null");
31+
AbstractTopic(String name) {
3532
this.name = name;
3633
}
3734

src/main/java/org/springframework/data/redis/listener/ChannelTopic.java

+14-10
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
*/
1616
package org.springframework.data.redis.listener;
1717

18+
import org.springframework.util.Assert;
19+
1820
/**
1921
* {@link Topic Channel Topic} implementation mapping to a Redis channel.
2022
*
@@ -25,22 +27,24 @@
2527
public class ChannelTopic extends AbstractTopic {
2628

2729
/**
28-
* Create a new {@link ChannelTopic} for channel subscriptions.
30+
* Constructs a new {@link ChannelTopic} instance.
2931
*
30-
* @param channelName {@link String name} of the Redis channel; must not be {@literal null} or {@literal empty}.
31-
* @return the {@link ChannelTopic} for the given {@code channelName}.
32-
* @since 2.1
32+
* @param channelName must not be {@literal null}.
3333
*/
34-
public static ChannelTopic of(String channelName) {
35-
return new ChannelTopic(channelName);
34+
public ChannelTopic(String channelName) {
35+
36+
super(channelName);
37+
Assert.notNull(channelName, "Channel name must not be null");
3638
}
3739

3840
/**
39-
* Constructs a new {@link ChannelTopic} instance.
41+
* Create a new {@link ChannelTopic} for channel subscriptions.
4042
*
41-
* @param channelName must not be {@literal null}.
43+
* @param channelName {@link String name} of the Redis channel; must not be {@literal null}.
44+
* @return the {@link ChannelTopic} for the given {@code channelName}.
45+
* @since 2.1
4246
*/
43-
public ChannelTopic(String channelName) {
44-
super("Topic name", channelName);
47+
public static ChannelTopic of(String channelName) {
48+
return new ChannelTopic(channelName);
4549
}
4650
}

src/main/java/org/springframework/data/redis/listener/PatternTopic.java

+14-10
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
*/
1616
package org.springframework.data.redis.listener;
1717

18+
import org.springframework.util.Assert;
19+
1820
/**
1921
* {@link Topic} {@link String pattern} matching multiple Redis channels.
2022
*
@@ -25,22 +27,24 @@
2527
public class PatternTopic extends AbstractTopic {
2628

2729
/**
28-
* Create a new {@link PatternTopic} for channel subscriptions based on a {@code pattern}.
30+
* Constructs a new {@link PatternTopic} instance.
2931
*
30-
* @param pattern {@link String pattern} used to match channels; must not be {@literal null} or {@literal empty}.
31-
* @return the {@link PatternTopic} for the given {@code pattern}.
32-
* @since 2.1
32+
* @param channelPattern must not be {@literal null}.
3333
*/
34-
public static PatternTopic of(String pattern) {
35-
return new PatternTopic(pattern);
34+
public PatternTopic(String channelPattern) {
35+
36+
super(channelPattern);
37+
Assert.notNull(channelPattern, "Pattern must not be null");
3638
}
3739

3840
/**
39-
* Constructs a new {@link PatternTopic} instance.
41+
* Create a new {@link PatternTopic} for channel subscriptions based on a {@code pattern}.
4042
*
41-
* @param channelPattern must not be {@literal null}.
43+
* @param pattern {@link String pattern} used to match channels; must not be {@literal null} or empty.
44+
* @return the {@link PatternTopic} for the given {@code pattern}.
45+
* @since 2.1
4246
*/
43-
public PatternTopic(String channelPattern) {
44-
super("Pattern", channelPattern);
47+
public static PatternTopic of(String pattern) {
48+
return new PatternTopic(pattern);
4549
}
4650
}

0 commit comments

Comments
 (0)