Buen día.
Hice un Array de Objetos, y quisiera saber cómo podría optimizarlo.
Mi código es el siguiente
Gson gson = new Gson();
String idPerfil = "R65";
String idWorkPlace = "0073";
String workPlace = null;
String response = null;
WorkPlace territories = new WorkPlace();
WorkPlace zones = new WorkPlace();
WorkPlace offices = new WorkPlace();
WorkPlace jobs = new WorkPlace();
WorkPlace employees = new WorkPlace();
WorkPlace customers = new WorkPlace();
if(perfilOficina.contains(idPerfil)){
WorkPlaceDetail workPlaceDetail = srvBranchesV00.getBrachesWorkplace(idWorkPlace);
ArrayList<WorkPlace> workp = new ArrayList<WorkPlace>();
territories.setId("Territoriales");
territories.setName("");
zones.setId("Zonas");
zones.setName("");
offices.setId("Oficinas");
offices.setName(workPlace);
jobs.setId("Cargos");
jobs.setName("");
employees.setId("Funcionarios");
employees.setName("");
customers.setId("Clientes");
customers.setName("");
workp.add(territories);
workp.add(zones);
workp.add(offices);
workp.add(jobs);
workp.add(employees);
workp.add(customers);
response = gson.toJson(workp);