Merge pull request #771 from dkoper/master

the change I meant to pull request earlier today: used in FGCP's DefaultNetwork
This commit is contained in:
Adrian Cole 2012-08-06 08:06:28 -07:00
commit d6aea87ab5
2 changed files with 50 additions and 0 deletions

View File

@ -205,6 +205,22 @@ public abstract class BaseTemplateBuilderLiveTest extends BaseComputeServiceCont
|| location.getParent().getIso3166Codes().containsAll(location.getIso3166Codes()) : location + " ||"
+ location.getParent();
break;
case SYSTEM:
Location systemParent = location.getParent();
// loop up to root, which must be the provider
while (systemParent.getParent() != null) {
systemParent = systemParent.getParent();
}
assertProvider(systemParent);
break;
case NETWORK:
Location networkParent = location.getParent();
// loop up to root, which must be the provider
while (networkParent.getParent() != null) {
networkParent = networkParent.getParent();
}
assertProvider(networkParent);
break;
case HOST:
Location provider2 = location.getParent().getParent().getParent();
// zone can be a direct descendant of provider

View File

@ -86,6 +86,40 @@ public class LocationPredicates {
}
}
public static Predicate<Location> isSystem() {
return IsSystem.INSTANCE;
}
static enum IsSystem implements Predicate<Location> {
INSTANCE;
@Override
public boolean apply(Location input) {
return input.getScope() == LocationScope.SYSTEM;
}
@Override
public String toString() {
return "isSystem()";
}
}
public static Predicate<Location> isNetwork() {
return IsNetwork.INSTANCE;
}
static enum IsNetwork implements Predicate<Location> {
INSTANCE;
@Override
public boolean apply(Location input) {
return input.getScope() == LocationScope.NETWORK;
}
@Override
public String toString() {
return "isNetwork()";
}
}
public static Predicate<Location> idEquals(String id) {
return new IdEquals(id);
}