-
Notifications
You must be signed in to change notification settings - Fork 118
/
Copy pathConsumer.java
68 lines (54 loc) · 1.5 KB
/
Consumer.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
package com.purbon.kafka.topology.model.users;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.purbon.kafka.topology.model.User;
import com.purbon.kafka.topology.roles.rbac.RBACPredefinedRoles;
import java.util.Objects;
import java.util.Optional;
public class Consumer extends User {
private Optional<String> group;
@JsonProperty(value = "group-role")
private String groupRole = RBACPredefinedRoles.RESOURCE_OWNER;
public Consumer() {
super();
group = Optional.empty();
}
public Consumer(String principal) {
this(principal, null);
}
public Consumer(String principal, String group) {
super(principal);
this.group = Optional.ofNullable(group);
}
public String groupString() {
return group.orElse("*");
}
public Optional<String> getGroup() {
return group;
}
public void setGroup(Optional<String> group) {
this.group = group;
}
public String getGroupRole() {
return groupRole;
}
public void setGroupRole(String groupRole) {
this.groupRole = groupRole;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof Consumer)) {
return false;
}
Consumer consumer = (Consumer) o;
return getPrincipal().equals(consumer.getPrincipal())
&& groupRole.equals(consumer.getGroupRole())
&& groupString().equals(consumer.groupString());
}
@Override
public int hashCode() {
return Objects.hash(groupString(), getPrincipal(), groupRole);
}
}