private static ApplicationDetail toApplicationDetail(
      ApplicationStatisticsResponse applicationStatisticsResponse,
      SummaryApplicationResponse summaryApplicationResponse,
      GetStackResponse getStackResponse,
      ApplicationInstancesResponse applicationInstancesResponse) {

    return ApplicationDetail.builder()
        .buildpack(getBuildpack(summaryApplicationResponse))
        .diskQuota(summaryApplicationResponse.getDiskQuota())
        .id(summaryApplicationResponse.getId())
        .instanceDetails(
            toInstanceDetailList(applicationInstancesResponse, applicationStatisticsResponse))
        .instances(summaryApplicationResponse.getInstances())
        .lastUploaded(toDate(summaryApplicationResponse.getPackageUpdatedAt()))
        .memoryLimit(summaryApplicationResponse.getMemory())
        .name(summaryApplicationResponse.getName())
        .requestedState(summaryApplicationResponse.getState())
        .runningInstances(summaryApplicationResponse.getRunningInstances())
        .stack(getStackResponse.getEntity().getName())
        .urls(toUrls(summaryApplicationResponse.getRoutes()))
        .build();
  }
 private static String getBuildpack(SummaryApplicationResponse response) {
   return Optional.ofNullable(response.getBuildpack()).orElse(response.getDetectedBuildpack());
 }