> +                             && 
> ruleEqualsIpPermission(permission).apply(Iterables.getOnlyElement(input.getAllowed())));
> +         }
> +      };
> +   }
> +
> +   public static Predicate<Firewall> providesIpPermission(final IpPermission 
> permission) {
> +      return new Predicate<Firewall>() {
> +         @Override
> +         public boolean apply(Firewall input) {
> +            return ((permission.getGroupIds().size() == 0 && 
> input.getSourceTags().size() == 0)
> +                       || Sets.intersection(permission.getGroupIds(), 
> input.getSourceTags()).size() > 0)
> +                      && ((permission.getCidrBlocks().size() == 0 && 
> input.getSourceRanges().size() == 0)
> +                             || 
> Sets.intersection(permission.getCidrBlocks(), input.getSourceRanges()).size() 
> > 0)
> +                      && hasProtocol(permission.getIpProtocol()).apply(input)
> +                      && ((permission.getFromPort() == 0 && 
> permission.getToPort() == 0)
> +                             || 
> hasPortRange(Range.closed(permission.getFromPort(), 
> permission.getToPort())).apply(input));

Break up into three booleans to aid understanding?
```
boolean groupIdsMatchSourceTags = ...;
boolean cidrBlocksMatchSourceRanges = ...;
boolean firewallHasPortRange = ...;
return groupIdsMatchSourceTags  && cidrBlocksMatchSourceRanges  
         && hasProtocol(permission.getIpProtocol()).apply(input) && 
firewallHasPortRange;
```

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/5/files#r7381254

Reply via email to