From 86817b76128d7f1781ec9c61efb0128c4ea67146 Mon Sep 17 00:00:00 2001 From: Jeremy Whitlock Date: Thu, 26 May 2011 10:21:46 -0600 Subject: [PATCH] Issue 550: Refactored the ISO 3166 filtering methods for Providers API. * core/src/main/java/org/jclouds/providers/ProviderPredicates.java (inIso3166Code): Deleted. (boundedByIso3166Code): Added. * core/src/main/java/org/jclouds/providers/Providers.java (withIso3166Code): Deleted. (boundedByIso3166Code): Added. * core/src/test/java/org/jclouds/providers/ProvidersTest.java (testWithIso3166Code): Deleted. (testBoundedByIso3166Code): Added (testIntersectingIso3166Code): Deleted. (testCollocatedWith): Added. --- .../org/jclouds/providers/ProviderPredicates.java | 11 ++++++----- .../main/java/org/jclouds/providers/Providers.java | 6 +++--- .../java/org/jclouds/providers/ProvidersTest.java | 6 +++--- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/core/src/main/java/org/jclouds/providers/ProviderPredicates.java b/core/src/main/java/org/jclouds/providers/ProviderPredicates.java index dc8ad7e3a7..1ed1c542d5 100644 --- a/core/src/main/java/org/jclouds/providers/ProviderPredicates.java +++ b/core/src/main/java/org/jclouds/providers/ProviderPredicates.java @@ -99,13 +99,14 @@ public class ProviderPredicates { } /** - * Returns all providers that are "in" the given ISO 3166 code. + * Returns the providers that are bound to the same location as the given ISO 3166 code. * - * @param iso3166Code the ISO 3166 code for the location/region to search for + * @param isoCode + * the ISO 3166 code to filter providers by * - * @return the providers "in" the given ISO 3166 code + * @return the providers with the given ISO 3166 code */ - public static Predicate inIso3166Code(final String iso3166Code) { + public static Predicate boundedByIso3166Code(final String iso3166Code) { Preconditions.checkNotNull(iso3166Code, "iso3166Code must not be null"); return new Predicate() { @@ -122,7 +123,7 @@ public class ProviderPredicates { */ @Override public String toString() { - return "inIso3166Code(" + iso3166Code + ")"; + return "boundedByIso3166Code(" + iso3166Code + ")"; } }; } diff --git a/core/src/main/java/org/jclouds/providers/Providers.java b/core/src/main/java/org/jclouds/providers/Providers.java index e429a65329..0f4d0e8c92 100644 --- a/core/src/main/java/org/jclouds/providers/Providers.java +++ b/core/src/main/java/org/jclouds/providers/Providers.java @@ -127,15 +127,15 @@ public class Providers { } /** - * Returns the providers that have the given ISO 3166 code regardless of type. + * Returns the providers that are bound to the same location as the given ISO 3166 code. * * @param isoCode * the ISO 3166 code to filter providers by * * @return the providers with the given ISO 3166 code */ - public static Iterable withIso3166Code(String iso3166Code) { - return filter(all(), ProviderPredicates.inIso3166Code(iso3166Code)); + public static Iterable boundedByIso3166Code(String iso3166Code) { + return filter(all(), ProviderPredicates.boundedByIso3166Code(iso3166Code)); } /** diff --git a/core/src/test/java/org/jclouds/providers/ProvidersTest.java b/core/src/test/java/org/jclouds/providers/ProvidersTest.java index a1cc5fa7f5..152ed5bc70 100644 --- a/core/src/test/java/org/jclouds/providers/ProvidersTest.java +++ b/core/src/test/java/org/jclouds/providers/ProvidersTest.java @@ -95,7 +95,7 @@ public class ProvidersTest { } @Test - public void testWithIso3166Code() { + public void testBoundedByIso3166Code() { @SuppressWarnings("serial") Map expectedResults = new HashMap() {{ put("US-CA", 2); @@ -107,7 +107,7 @@ public class ProvidersTest { }}; for (Map.Entry result : expectedResults.entrySet()) { - Iterable providersMetadata = Providers.withIso3166Code(result.getKey()); + Iterable providersMetadata = Providers.boundedByIso3166Code(result.getKey()); int providersFound = 0; for (ProviderMetadata providerMetadata : providersMetadata) { @@ -121,7 +121,7 @@ public class ProvidersTest { } @Test - public void testIntersectingIso3166Code() { + public void testCollocatedWith() { @SuppressWarnings("serial") Map expectedResults = new HashMap() {{ put(testBlobstoreProvider, 1);