You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jclouds.apache.org by an...@apache.org on 2013/11/07 14:19:41 UTC
git commit: JCLOUDS-369: Added a new predicate to capture disk links
Updated Branches:
refs/heads/master c5d6f6b14 -> d9717a432
JCLOUDS-369: Added a new predicate to capture disk links
Added a new predicate to capture disk links
Project: http://git-wip-us.apache.org/repos/asf/jclouds-labs/repo
Commit: http://git-wip-us.apache.org/repos/asf/jclouds-labs/commit/d9717a43
Tree: http://git-wip-us.apache.org/repos/asf/jclouds-labs/tree/d9717a43
Diff: http://git-wip-us.apache.org/repos/asf/jclouds-labs/diff/d9717a43
Branch: refs/heads/master
Commit: d9717a432fcd1a2512f4a5d121b9454822f928e7
Parents: c5d6f6b
Author: Carlos Garcia <ca...@emea.nec.com>
Authored: Tue Nov 5 10:48:23 2013 +0100
Committer: Andrew Phillips <an...@apache.org>
Committed: Thu Nov 7 08:19:21 2013 -0500
----------------------------------------------------------------------
.../abiquo/predicates/LinkPredicates.java | 20 +++++++++++++++++++-
1 file changed, 19 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/d9717a43/abiquo/src/main/java/org/jclouds/abiquo/predicates/LinkPredicates.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/predicates/LinkPredicates.java b/abiquo/src/main/java/org/jclouds/abiquo/predicates/LinkPredicates.java
index 524fcfe..31f4907 100644
--- a/abiquo/src/main/java/org/jclouds/abiquo/predicates/LinkPredicates.java
+++ b/abiquo/src/main/java/org/jclouds/abiquo/predicates/LinkPredicates.java
@@ -18,7 +18,11 @@ package org.jclouds.abiquo.predicates;
import static com.google.common.base.Preconditions.checkNotNull;
+import java.util.regex.Pattern;
+
import com.abiquo.model.rest.RESTLink;
+import com.abiquo.server.core.infrastructure.network.NicDto;
+import com.abiquo.server.core.infrastructure.storage.VolumeManagementDto;
import com.google.common.base.Predicate;
/**
@@ -27,6 +31,10 @@ import com.google.common.base.Predicate;
* @author Ignasi Barrera
*/
public class LinkPredicates {
+
+ private static final Pattern IS_NIC_REL_PATTERN = Pattern.compile("^" + NicDto.REL_PREFIX + "[0-9]+$");
+ private static final Pattern IS_DISK_REL_PATTERN = Pattern.compile("^" + VolumeManagementDto.REL_PREFIX + "[0-9]+$");
+
public static Predicate<RESTLink> rel(final String rel) {
checkNotNull(rel, "rel must be defined");
return new Predicate<RESTLink>() {
@@ -41,8 +49,18 @@ public class LinkPredicates {
return new Predicate<RESTLink>() {
@Override
public boolean apply(final RESTLink link) {
- return link.getRel().matches("^nic[0-9]+$");
+ return IS_NIC_REL_PATTERN.matcher(link.getRel()).matches();
+ }
+ };
+ }
+
+ public static Predicate<RESTLink> isDisk() {
+ return new Predicate<RESTLink>() {
+ @Override
+ public boolean apply(RESTLink link) {
+ return IS_DISK_REL_PATTERN.matcher(link.getRel()).matches();
}
};
}
+
}