//このクラスは仮です package com.example.cosmos_serversb.jsons; import com.example.cosmos_serversb.entities.Group; import com.example.cosmos_serversb.entities.Request; import com.example.cosmos_serversb.entities.User; import java.util.HashMap; import java.util.Map; import java.util.Set; public class GroupJson { private String gId; private String uri, name; private Map<String, String> members = new HashMap<>();//HashSetでいいのかな? private Map<String, String> requests = new HashMap<>(); public GroupJson(Group group){ setgId(group.getgId()); setUri(group.getUri()); setName(group.getName()); changeMembersMap(group.getMembers()); changeRequestsMap(group.getRequests()); } public String getgId() { return gId; } private void setgId(String gId) { this.gId = gId; } public String getUri() { return uri; } private void setUri(String uri){ this.uri = uri; } public String getUriByGid(String gId){ return uri; } private void setName(String name){ this.name = name; } public String getName(){ return name; } public String getNameByGid(String gId){ return name; } public Map<String, String> getMembers() { return members; } public void setMembers(Map<String, String> members) { this.members = members; } public Map<String, String> getRequests() { return requests; } public void setRequests(Map<String, String> requests) { this.requests = requests; } private void changeMembersMap(Set set){ for ( User user : (Set<User>) set ) { members.put(user.getuId(), getUri()); } } private void changeRequestsMap(Set set){ for ( Request request : (Set<Request>) set ) { requests.put(request.getrId(), getUri()); } } }