I totally agree: I've created two static Pattern objects to avoid the
compilation each time (one for the NIC rel and one for the new DISK rel).
I found the constant REL_PREFIX alreaady defined in the VolumeManagementDto
class, so I'm just using it. Anyway, I've removed the static import to
reflect its origin when used.


On Thu, Nov 7, 2013 at 3:56 AM, Andrew Phillips <notifications@github.com>wrote:

> In abiquo/src/main/java/org/jclouds/abiquo/predicates/LinkPredicates.java:
>
> > @@ -45,4 +46,13 @@ public boolean apply(final RESTLink link) {
> >           }
> >        };
> >     }
> > +
> > +   public static Predicate<RESTLink> isDisk() {
> > +      return new Predicate<RESTLink>() {
> > +         @Override
> > +         public boolean apply(RESTLink link) {
> > +            return link.getRel().matches("^" + REL_PREFIX + "[0-9]+$");
>
> Would it make sense to avoid the cost of compiling the pattern every time
> by declaring a constant IS_DISK_REL_PREFIX_PATTERN Pattern<http://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html>and doing something like
>
> public boolean apply(RESTLink link) {
>   return IS_DISK_REL_PREFIX_PATTERN.matcher(link.getRel()).matches();
> }
>
> Also, just out of curiosity: how does REL_PREFIX following by numbers mean
> "it's a disk"? If the REL_PREFIX is unique to disks, should it perhaps be
> called DISK_REL_PREFIX or so instead?
>
> —
> Reply to this email directly or view it on GitHub<https://github.com/jclouds/jclouds-labs/pull/32/files#r7486206>
> .
>