Source:
public NodeMetadata apply(Instance from) { NodeMetadataBuilder builder = new NodeMetadataBuilder(); Optional<? extends Image> image = findImage(from.imageId()); if (image.isPresent()) { builder.imageId(image.get().getId()); builder.operatingSystem(image.get().getOperatingSystem()); } else { logger.info(">> image with id %s for instance %s was not found. " + "This might be because the image that was used to create the instance has a new id.", from.instanceType(), from.instanceId()); } Optional<? extends Hardware> hardware = findHardware(from.instanceType()); if (hardware.isPresent()) { builder.hardware(hardware.get()); } else { logger.info(">> hardware with id %s for instance %s was not found. " + "This might be because the image that was used to create the instance has a new id.", from.instanceType(), from.instanceId()); } builder.id(RegionAndId.slashEncodeRegionAndId(from.regionId(), from.instanceId())); builder.providerId(from.instanceId()); builder.name(from.instanceName()); builder.hostname(String.format("%s", from.hostname())); builder.group(groupNamingConvention.extractGroup(from.instanceName())); builder.status(toPortableStatus.apply(from.status())); builder.privateAddresses(from.innerIpAddress().entrySet().iterator().next().getValue()); builder.publicAddresses(from.publicIpAddress().entrySet().iterator().next().getValue()); builder.location(from(locations.get()).firstMatch(LocationPredicates.idEquals(from.regionId())).orNull()); if (from.tags() != null) { parseTagsFromValuesOfEmptyString(builder, from.tags()); } NodeMetadata nodeMetadata = builder.build(); return nodeMetadata; }

Target:
public NodeMetadata apply(Instance from) { NodeMetadataBuilder builder = new NodeMetadataBuilder(); Optional<? extends Image> image = findImage(from.imageId()); if (image.isPresent()) { builder.imageId(image.get().getId()); builder.operatingSystem(image.get().getOperatingSystem()); } else { logger.info(">> image with id %s for instance %s was not found. " + "This might be because the image that was used to create the instance has a new id.", from.instanceType(), from.id()); } Optional<? extends Hardware> hardware = findHardware(from.instanceType()); if (hardware.isPresent()) { builder.hardware(hardware.get()); } else { logger.info(">> hardware with id %s for instance %s was not found. " + "This might be because the image that was used to create the instance has a new id.", from.instanceType(), from.id()); } builder.id(RegionAndId.slashEncodeRegionAndId(from.regionId(), from.id())); builder.providerId(from.id()); builder.name(from.name()); builder.hostname(String.format("%s", from.hostname())); builder.group(groupNamingConvention.extractGroup(from.name())); builder.status(toPortableStatus.apply(from.status())); builder.privateAddresses(from.innerIpAddress().entrySet().iterator().next().getValue()); builder.publicAddresses(from.publicIpAddress().entrySet().iterator().next().getValue()); builder.location(from(locations.get()).firstMatch(LocationPredicates.idEquals(from.regionId())).orNull()); if (from.tags() != null && !from.tags().isEmpty()) { ImmutableMap.Builder tagsBuilder = new ImmutableMap.Builder(); for (Tag tag : from.tags().entrySet().iterator().next().getValue()) { tagsBuilder.put(tag.key(), tag.value()); } addMetadataAndParseTagsFromValuesOfEmptyString(builder, tagsBuilder.build()); } NodeMetadata nodeMetadata = builder.build(); return nodeMetadata; }