Source:
private void loadOpenShiftData() { final ProjectDescriptor descriptor = checkNotNull(appContext.getCurrentProject()).getProjectDescription(); view.show(); view.setApplicationName(descriptor.getName()); osService.getProjects().then(new Operation<List<Project>>() { @Override public void apply(List<Project> projects) throws OperationException { if (projects == null || projects.isEmpty()) { return; } osProjects = unmodifiableList(projects); view.setProjects(osProjects); } }).then(osService.getImageStreams("openshift", null).then(new Operation<List<ImageStream>>() { @Override public void apply(List<ImageStream> streams) throws OperationException { if (streams == null || streams.isEmpty()) { return; } osImageStreams = unmodifiableList(streams); final List<String> imageNames = Lists.transform(osImageStreams, new com.google.common.base.Function<ImageStream, String>() { @Override public String apply(ImageStream input) { return input.getMetadata().getName(); } }); view.setImages(imageNames); view.setLabels(Collections.<Pair<String, String>>emptyList()); osService.getImageStreamTag("openshift", streams.get(0).getMetadata().getName(), "latest") .then(new Operation<ImageStreamTag>() { @Override public void apply(ImageStreamTag streamTag) throws OperationException { if (streamTag == null) { return; } osActiveStreamTag = streamTag; List<Pair<String, String>> variables = new ArrayList<Pair<String, String>>(); for (String env : streamTag.getDockerImageMetadata().getContainerConfig().getEnv()) { String[] pair = env.split("="); if (pair.length != 2) { continue; } variables.add(new Pair<String, String>(pair[0], pair[1])); } view.setEnvironmentVariables(variables); } }); } })); }

Target:
private void loadOpenShiftData() { final ProjectDescriptor descriptor = checkNotNull(appContext.getCurrentProject()).getProjectDescription(); view.show(); view.setApplicationName(descriptor.getName()); osService.getProjects().then(new Operation<List<Project>>() { @Override public void apply(List<Project> projects) throws OperationException { if (projects == null || projects.isEmpty()) { return; } osProjects = unmodifiableList(projects); view.setProjects(osProjects); } }).then(osService.getImageStreams("openshift", null).then(new Operation<List<ImageStream>>() { @Override public void apply(List<ImageStream> streams) throws OperationException { if (streams == null || streams.isEmpty()) { return; } osImageStreams = unmodifiableList(streams); final List<String> imageNames = Lists.transform(osImageStreams, new com.google.common.base.Function<ImageStream, String>() { @Override public String apply(ImageStream input) { return input.getMetadata().getName(); } }); view.setImages(imageNames); view.setLabels(Collections.<Pair<String, String>>emptyList()); osService.getImageStreamTag("openshift", streams.get(0).getMetadata().getName(), "latest") .then(new Operation<ImageStreamTag>() { @Override public void apply(ImageStreamTag streamTag) throws OperationException { if (streamTag == null) { return; } osActiveStreamTag = streamTag; List<Pair<String, String>> variables = new ArrayList<>(); for (String env : streamTag.getDockerImageMetadata().getContainerConfig().getEnv()) { String[] keyValuePair = env.split("="); if (keyValuePair.length != 2) { continue; } variables.add(new Pair<>(keyValuePair[0], keyValuePair[1])); } view.setEnvironmentVariables(variables); } }); } })); }