package com.example.cosmos_serversb.jsons; import com.example.cosmos_serversb.entities.Request; import java.util.ArrayList; import java.util.Set; public class RequestsJson { public ArrayList<RequestJson> requests = new ArrayList<>(); public RequestsJson(Set<Request> set, int quantity){ changeRequests(set, quantity); } public ArrayList<RequestJson> getRequests(){ return requests; } public void setRequests(ArrayList<RequestJson> requests) { this.requests = requests; } private void changeRequests(Set<Request> set, int quantity){ if(quantity <= 0) return; for( Request request : (Set<Request>) set ) { requests.add(new RequestJson(request)); if(requests.size() == quantity) break; } } }