> +      Optional<? extends SecurityGroupApi> sgApi = 
> client.getSecurityGroupExtensionForZone(zone);
> +
> +      if (!serverApi.isPresent() || !sgApi.isPresent()) {
> +         return ImmutableSet.of();
> +      }
> +
> +      ServerWithSecurityGroups instance = serverApi.get().get(instanceId);
> +      if (instance == null) {
> +         return ImmutableSet.of();
> +      }
> +
> +      Set<String> groupNames = instance.getSecurityGroupNames();
> +      Set<? extends SecurityGroupInZone> rawGroups =
> +              
> sgApi.get().list().filter(nameIn(groupNames)).transform(groupToGroupInZone(zone)).toSet();
> +
> +      return ImmutableSet.copyOf(transform(filter(rawGroups, notNull()), 
> groupConverter));

The "filter-then-convert" pattern appears in a couple of places...factor out 
into a method or function?

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/144/files#r6344642

Reply via email to