The method below converts an array of TheatreListData objects to an array of TheatreListDataWrapper. It also loads additional attributes such as patientIdentifierNumber and requestText to enrich the converted data.This method is called by many EJBs, and so I'm especially looking for ways to improve performance./** * Converts TheatreListDatas into TheatreListDataWrappers. This also * loads the attributes that has to be generated from client such as * patientIdentifierNumber, requestText * * @param theatreListData * @return TheatreListDataWrapper[] */public TheatreListDataWrapper[] wrapData(TheatreListData[] theatreListData){    TheatreListDataWrapper[] wrapperList = wrapDataWithoutRequestData(theatreListData);    if (wrapperList != null && wrapperList.length > 0)    {      Set<String> requestIds = new HashSet<String>();      for (TheatreListData listData : theatreListData)      {        // Collect request id for each List Data into a set        String requestId = listData.getCarePlan().requestId;        //Should check for '-1' here to avoid calls to fetch invalid requests.        //'-1' could have been saved with registrations with 'None' requests.        if (requestId != null && requestId.trim().length() > 0 && !requestId.equals(-1))        {          //Since adding to a set no duplicates are possible.          requestIds.add(requestId);        }      }      //Load request Id, request Text map using the collected request ids.      Map<String, String> requestMap = Collections.emptyMap();      if (!requestIds.isEmpty())      {        requestMap = getRequestDelegator().getRequestPresentationStringsByIds(new ArrayList<String>(requestIds));      }      //Create wrappers & fill with loaded data.      for (int i = 0; i < theatreListData.length; i++)      {        TheatreListDataWrapper wrapper = wrapperList[i];        TheatreListData listData = theatreListData[i];        String requestId = listData.getCarePlan().requestId;        if (requestId != null && requestId.trim().length() > 0)        {          wrapper.requestText = requestMap.get(requestId) != null ? requestMap.get(requestId) : ;        }        wrapperList[i] = wrapper;      }    }    return wrapperList;  }
Converting and enriching an array of data
java