Skip to content

Commit a7c6828

Browse files
committed
add: Group#getMembers method
1 parent 31295d5 commit a7c6828

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

src/main/java/top/focess/qq/api/bot/Group.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
package top.focess.qq.api.bot;
22

3+
import org.checkerframework.checker.nullness.qual.NonNull;
4+
5+
import java.util.List;
6+
37
public interface Group extends Speaker{
48

59
/**
@@ -22,5 +26,11 @@ public interface Group extends Speaker{
2226
*/
2327
Member getMemberOrFail(long id);
2428

29+
/**
30+
* Get the group's all members
31+
* @return the all members
32+
*/
33+
@NonNull
34+
List<Member> getMembers();
2535

2636
}

src/main/java/top/focess/qq/core/bot/SimpleGroup.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
package top.focess.qq.core.bot;
22

33
import com.google.common.collect.Maps;
4+
import org.checkerframework.checker.nullness.qual.NonNull;
45
import org.jetbrains.annotations.Nullable;
56
import top.focess.qq.api.bot.Bot;
67
import top.focess.qq.api.bot.Group;
78
import top.focess.qq.api.bot.Member;
89

10+
import java.util.List;
911
import java.util.Map;
12+
import java.util.Objects;
13+
import java.util.stream.Collectors;
1014

1115
public class SimpleGroup extends SimpleSpeaker implements Group {
1216

@@ -51,6 +55,12 @@ public Member getMember(long id) {
5155

5256
@Override
5357
public Member getMemberOrFail(long id) {
54-
return SimpleMember.get(this,this.nativeGroup.getOrFail(id));
58+
return Objects.requireNonNull(SimpleMember.get(this,this.nativeGroup.getOrFail(id)));
5559
}
60+
61+
@Override
62+
public @NonNull List<Member> getMembers() {
63+
return this.nativeGroup.getMembers().stream().map(i -> SimpleMember.get(this,i)).collect(Collectors.toList());
64+
}
65+
5666
}

0 commit comments

Comments
 (0)