-
Notifications
You must be signed in to change notification settings - Fork 22
/
GroupedTopicSource.java
73 lines (60 loc) · 1.74 KB
/
GroupedTopicSource.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package forklift.source.sources;
import forklift.source.ActionSource;
import forklift.source.SourceI;
import forklift.source.decorators.GroupedTopic;
import java.util.Objects;
/**
* A more easily usable form of the annotation {@code @GroupTopic}.
*/
public class GroupedTopicSource extends ActionSource {
private final String name;
private String group;
public GroupedTopicSource(String name, String group) {
this.name = name;
this.group = group;
}
public GroupedTopicSource(GroupedTopic topic) {
this.name = topic.name();
this.group = topic.group();
}
public String getName() {
return name;
}
public String getGroup() {
return group;
}
/**
* Determines whether or not the current group name is a null-like value, and should be changed.
*
* @return whether a group name is specified
*/
public boolean groupSpecified() {
return group != null && !group.isEmpty();
}
/**
* Allow changing the group name here, so the group name can be ultimiately
* determined by the connector.
*
* @param group the new group to use
*/
public void overrideGroup(String group) {
this.group = group;
}
@Override
public int hashCode() {
return Objects.hash(name, group);
}
@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (!(o instanceof GroupedTopicSource))
return false;
GroupedTopicSource that = (GroupedTopicSource) o;
return Objects.equals(this.name, that.name);
}
@Override
public String toString() {
return "GroupedTopicSource(name=" + name + ", group=" + group + ")";
}
}