Source:
<code>public NodeMetadata apply(ServerInZone serverInZone) { Location zone = locationIndex.get().get(serverInZone.getZone()); checkState(zone != null, "location %s not in locationIndex: %s", serverInZone.getZone(), locationIndex.get()); Server from = serverInZone.getServer(); NodeMetadataBuilder builder = new NodeMetadataBuilder(); builder.id(serverInZone.slashEncode()); builder.providerId(from.getId()); builder.name(from.getName()); builder.hostname(from.getName()); builder.location(from.getHostId() != null ? new LocationBuilder().scope(LocationScope.HOST).id(from.getHostId()) .description(from.getHostId()).parent(zone).build() : zone); if (from.getMetadata().get("jclouds-group") != null) { builder.group(from.getMetadata().get("jclouds-group")); } else { builder.group(nodeNamingConvention.groupInUniqueNameOrNull(from.getName())); <START> } <END> addMetadataAndParseTagsFromCommaDelimitedValue(builder, from.getMetadata()); builder.imageId(ZoneAndId.fromZoneAndId(serverInZone.getZone(), from.getImage().getId()).slashEncode()); builder.operatingSystem(findOperatingSystemForServerOrNull(serverInZone)); builder.hardware(findHardwareForServerOrNull(serverInZone)); builder.status(toPortableNodeStatus.get(from.getStatus())); builder.publicAddresses(filter( transform(filter(from.getAddresses().values(), Predicates.not(isPrivateAddress)), AddressToStringTransformationFunction.INSTANCE), isInet4Address)); builder.privateAddresses(filter( transform(filter(from.getAddresses().values(), isPrivateAddress), AddressToStringTransformationFunction.INSTANCE), isInet4Address)); for (Link link: from.getLinks()) { if (link.getRelation().equals(Link.Relation.SELF)) { builder.uri(link.getHref()); } } return builder.build(); }</code><technical_language>This pattern crops in a couple of places...extract a helper utility method somewhere..</technical_language>

Target:
public NodeMetadata apply(ServerInZone serverInZone) { Location zone = locationIndex.get().get(serverInZone.getZone()); checkState(zone != null, "location %s not in locationIndex: %s", serverInZone.getZone(), locationIndex.get()); Server from = serverInZone.getServer(); NodeMetadataBuilder builder = new NodeMetadataBuilder(); builder.id(serverInZone.slashEncode()); builder.providerId(from.getId()); builder.name(from.getName()); builder.hostname(from.getName()); builder.location(from.getHostId() != null ? new LocationBuilder().scope(LocationScope.HOST).id(from.getHostId()) .description(from.getHostId()).parent(zone).build() : zone); builder.group(groupFromMapOrName(from.getMetadata(), from.getName(), nodeNamingConvention)); addMetadataAndParseTagsFromCommaDelimitedValue(builder, from.getMetadata()); builder.imageId(ZoneAndId.fromZoneAndId(serverInZone.getZone(), from.getImage().getId()).slashEncode()); builder.operatingSystem(findOperatingSystemForServerOrNull(serverInZone)); builder.hardware(findHardwareForServerOrNull(serverInZone)); builder.status(toPortableNodeStatus.get(from.getStatus())); builder.publicAddresses(filter( transform(filter(from.getAddresses().values(), Predicates.not(isPrivateAddress)), AddressToStringTransformationFunction.INSTANCE), isInet4Address)); builder.privateAddresses(filter( transform(filter(from.getAddresses().values(), isPrivateAddress), AddressToStringTransformationFunction.INSTANCE), isInet4Address)); for (Link link: from.getLinks()) { if (link.getRelation().equals(Link.Relation.SELF)) { builder.uri(link.getHref()); } } return builder.build(); }