2 * Copyright (c) 2010-2023 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
7 * This program and the accompanying materials are made available under the
8 * terms of the Eclipse Public License 2.0 which is available at
9 * http://www.eclipse.org/legal/epl-2.0
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.heos.internal.json.payload;
15 import java.util.Collections;
16 import java.util.List;
17 import java.util.stream.Collectors;
19 import org.eclipse.jdt.annotation.NonNullByDefault;
21 import com.google.gson.annotations.SerializedName;
24 * Data class for response payloads when retrieving group (information)
26 * @author Martin van Wingerden - Initial contribution
30 @SerializedName("gid")
31 public String id = "";
32 public String name = "";
33 public List<Player> players = Collections.emptyList();
35 public String getGroupMemberIds() {
36 return players.stream().map(p -> p.id).collect(Collectors.joining(";"));
39 public String getLeaderId() {
40 return players.stream().filter(p -> p.role == GroupPlayerRole.LEADER).map(p -> p.id).findFirst()
41 .orElseThrow(() -> new IllegalStateException("Every group should have a leader"));
44 public static class Player {
45 @SerializedName("pid")
46 public String id = "";
47 public String name = "";
48 public GroupPlayerRole role = GroupPlayerRole.MEMBER;