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.ArrayList; import java.util.HashMap; import java.util.Map; import java.util.Set; public class GroupJson { private String gId; private String uri, name; private ArrayList<UidUriJson> members = new ArrayList<>(); private ArrayList<RidUriJson> requests = new ArrayList<>(); public GroupJson(Group group){ setgId(group.getgId()); setUri(group.getUri()); setName(group.getName()); createUidUri(group.getMembers()); createRidUri(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 ArrayList<UidUriJson> getMembers() { return members; } public void setMembers(ArrayList<UidUriJson> members) { this.members = members; } public ArrayList<RidUriJson> getRequest() { return requests; } public void setRequests(ArrayList<RidUriJson> requests) { this.requests = requests; } private void createUidUri(Set set){ for ( User user : (Set<User>) set ) { members.add( new UidUriJson(user) ); } } private void createRidUri(Set set){ for ( Request request : (Set<Request>) set ) { requests.add( new RidUriJson(request) ); } } }