http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/b41b0d04/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/BaseWithRegionToPagedIterable.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/BaseWithRegionToPagedIterable.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/BaseWithRegionToPagedIterable.java index a4cc52d..b02422c 100644 --- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/BaseWithRegionToPagedIterable.java +++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/BaseWithRegionToPagedIterable.java @@ -20,6 +20,7 @@ import static com.google.common.base.Predicates.instanceOf; import static com.google.common.collect.Iterables.tryFind; import org.jclouds.collect.IterableWithMarker; +import org.jclouds.collect.IterableWithMarkers; import org.jclouds.collect.PagedIterable; import org.jclouds.collect.PagedIterables; import org.jclouds.googlecomputeengine.domain.ListPage; @@ -38,10 +39,9 @@ public abstract class BaseWithRegionToPagedIterable<T, I extends BaseWithRegionT private GeneratedHttpRequest request; - @Override - public PagedIterable<T> apply(ListPage<T> input) { - if (input.nextMarker() == null) - return PagedIterables.of(input); + @Override public PagedIterable<T> apply(ListPage<T> input) { + if (input.nextPageToken() == null) + return PagedIterables.onlyPage(IterableWithMarkers.from(input)); Optional <Object> project = tryFind(request.getCaller().get().getArgs(), instanceOf(String.class)); @@ -55,8 +55,8 @@ public abstract class BaseWithRegionToPagedIterable<T, I extends BaseWithRegionT assert region.isPresent() : String.format("programming error, method %s should have a string param for the " + "region", request.getCaller().get().getInvokable()); - return PagedIterables.advance( - input, fetchNextPage(project.get().toString(), region.get().toString(), (ListOptions) listOptions.orNull())); + return PagedIterables.advance(IterableWithMarkers.from(input, input.nextPageToken()), + fetchNextPage(project.get().toString(), region.get().toString(), (ListOptions) listOptions.orNull())); } protected abstract Function<Object, IterableWithMarker<T>> fetchNextPage(String projectName,
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/b41b0d04/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/BaseWithZoneToPagedIterable.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/BaseWithZoneToPagedIterable.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/BaseWithZoneToPagedIterable.java index d9dcbf2..312ff10 100644 --- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/BaseWithZoneToPagedIterable.java +++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/BaseWithZoneToPagedIterable.java @@ -20,6 +20,7 @@ import static com.google.common.base.Predicates.instanceOf; import static com.google.common.collect.Iterables.tryFind; import org.jclouds.collect.IterableWithMarker; +import org.jclouds.collect.IterableWithMarkers; import org.jclouds.collect.PagedIterable; import org.jclouds.collect.PagedIterables; import org.jclouds.googlecomputeengine.domain.ListPage; @@ -38,10 +39,9 @@ public abstract class BaseWithZoneToPagedIterable<T, I extends BaseWithZoneToPag private GeneratedHttpRequest request; - @Override - public PagedIterable<T> apply(ListPage<T> input) { - if (input.nextMarker() == null) - return PagedIterables.of(input); + @Override public PagedIterable<T> apply(ListPage<T> input) { + if (input.nextPageToken() == null) + return PagedIterables.onlyPage(IterableWithMarkers.from(input)); Optional<Object> project = tryFind(request.getCaller().get().getArgs(), instanceOf(String.class)); @@ -55,8 +55,8 @@ public abstract class BaseWithZoneToPagedIterable<T, I extends BaseWithZoneToPag assert zone.isPresent() : String.format("programming error, method %s should have a string param for the " + "zone", request.getCaller().get().getInvokable()); - return PagedIterables.advance( - input, fetchNextPage(project.get().toString(), zone.get().toString(), (ListOptions) listOptions.orNull())); + return PagedIterables.advance(IterableWithMarkers.from(input, input.nextPageToken()), + fetchNextPage(project.get().toString(), zone.get().toString(), (ListOptions) listOptions.orNull())); } protected abstract Function<Object, IterableWithMarker<T>> fetchNextPage(String projectName, http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/b41b0d04/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseAddresses.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseAddresses.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseAddresses.java index f7a4d73..22da307 100644 --- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseAddresses.java +++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseAddresses.java @@ -16,12 +16,10 @@ */ package org.jclouds.googlecomputeengine.functions.internal; -import static com.google.common.base.Preconditions.checkNotNull; - import javax.inject.Inject; -import javax.inject.Singleton; import org.jclouds.collect.IterableWithMarker; +import org.jclouds.collect.IterableWithMarkers; import org.jclouds.googlecomputeengine.GoogleComputeEngineApi; import org.jclouds.googlecomputeengine.domain.Address; import org.jclouds.googlecomputeengine.domain.ListPage; @@ -32,11 +30,9 @@ import org.jclouds.json.Json; import com.google.common.base.Function; import com.google.inject.TypeLiteral; -@Singleton -public class ParseAddresses extends ParseJson<ListPage<Address>> { +public final class ParseAddresses extends ParseJson<ListPage<Address>> { - @Inject - public ParseAddresses(Json json) { + @Inject ParseAddresses(Json json) { super(json, new TypeLiteral<ListPage<Address>>() { }); } @@ -45,21 +41,18 @@ public class ParseAddresses extends ParseJson<ListPage<Address>> { private final GoogleComputeEngineApi api; - @Inject - protected ToPagedIterable(GoogleComputeEngineApi api) { - this.api = checkNotNull(api, "api"); + @Inject ToPagedIterable(GoogleComputeEngineApi api) { + this.api = api; } - @Override - protected Function<Object, IterableWithMarker<Address>> fetchNextPage(final String projectName, - final String regionName, - final ListOptions options) { + @Override protected Function<Object, IterableWithMarker<Address>> fetchNextPage(final String projectName, + final String regionName, final ListOptions options) { return new Function<Object, IterableWithMarker<Address>>() { - @Override - public IterableWithMarker<Address> apply(Object input) { - return api.getAddressApi(projectName) - .listAtMarkerInRegion(regionName, input.toString(), options); + @Override public IterableWithMarker<Address> apply(Object input) { + ListPage<Address> result = api.getAddressApi(projectName) + .listAtMarkerInRegion(regionName, input.toString(), options); + return IterableWithMarkers.from(result, result.nextPageToken()); } }; } http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/b41b0d04/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseDiskTypes.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseDiskTypes.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseDiskTypes.java index 891519d..b62f719 100644 --- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseDiskTypes.java +++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseDiskTypes.java @@ -16,14 +16,13 @@ */ package org.jclouds.googlecomputeengine.functions.internal; -import static com.google.common.base.Preconditions.checkNotNull; - import javax.inject.Inject; import org.jclouds.collect.IterableWithMarker; +import org.jclouds.collect.IterableWithMarkers; import org.jclouds.googlecomputeengine.GoogleComputeEngineApi; -import org.jclouds.googlecomputeengine.domain.ListPage; import org.jclouds.googlecomputeengine.domain.DiskType; +import org.jclouds.googlecomputeengine.domain.ListPage; import org.jclouds.googlecomputeengine.options.ListOptions; import org.jclouds.http.functions.ParseJson; import org.jclouds.json.Json; @@ -31,32 +30,29 @@ import org.jclouds.json.Json; import com.google.common.base.Function; import com.google.inject.TypeLiteral; -public class ParseDiskTypes extends ParseJson<ListPage<DiskType>> { +public final class ParseDiskTypes extends ParseJson<ListPage<DiskType>> { - @Inject - public ParseDiskTypes(Json json) { - super(json, new TypeLiteral<ListPage<DiskType>>() {}); + @Inject ParseDiskTypes(Json json) { + super(json, new TypeLiteral<ListPage<DiskType>>() { + }); } public static class ToPagedIterable extends BaseWithZoneToPagedIterable<DiskType, ToPagedIterable> { private final GoogleComputeEngineApi api; - @Inject - protected ToPagedIterable(GoogleComputeEngineApi api) { - this.api = checkNotNull(api, "api"); + @Inject ToPagedIterable(GoogleComputeEngineApi api) { + this.api = api; } - @Override - protected Function<Object, IterableWithMarker<DiskType>> fetchNextPage(final String project, - final String zone, - final ListOptions options) { + @Override protected Function<Object, IterableWithMarker<DiskType>> fetchNextPage(final String projectName, + final String zoneName, final ListOptions options) { return new Function<Object, IterableWithMarker<DiskType>>() { - @Override - public IterableWithMarker<DiskType> apply(Object input) { - return api.getDiskTypeApi(project) - .listAtMarkerInZone(zone, input.toString(), options); + @Override public IterableWithMarker<DiskType> apply(Object input) { + ListPage<DiskType> result = api.getDiskTypeApi(projectName) + .listAtMarkerInZone(zoneName, input.toString(), options); + return IterableWithMarkers.from(result, result.nextPageToken()); } }; } http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/b41b0d04/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseDisks.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseDisks.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseDisks.java index 2373838..03dd198 100644 --- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseDisks.java +++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseDisks.java @@ -16,12 +16,10 @@ */ package org.jclouds.googlecomputeengine.functions.internal; -import static com.google.common.base.Preconditions.checkNotNull; - import javax.inject.Inject; -import javax.inject.Singleton; import org.jclouds.collect.IterableWithMarker; +import org.jclouds.collect.IterableWithMarkers; import org.jclouds.googlecomputeengine.GoogleComputeEngineApi; import org.jclouds.googlecomputeengine.domain.Disk; import org.jclouds.googlecomputeengine.domain.ListPage; @@ -32,11 +30,9 @@ import org.jclouds.json.Json; import com.google.common.base.Function; import com.google.inject.TypeLiteral; -@Singleton -public class ParseDisks extends ParseJson<ListPage<Disk>> { +public final class ParseDisks extends ParseJson<ListPage<Disk>> { - @Inject - public ParseDisks(Json json) { + @Inject ParseDisks(Json json) { super(json, new TypeLiteral<ListPage<Disk>>() { }); } @@ -45,21 +41,18 @@ public class ParseDisks extends ParseJson<ListPage<Disk>> { private final GoogleComputeEngineApi api; - @Inject - protected ToPagedIterable(GoogleComputeEngineApi api) { - this.api = checkNotNull(api, "api"); + @Inject ToPagedIterable(GoogleComputeEngineApi api) { + this.api = api; } - @Override - protected Function<Object, IterableWithMarker<Disk>> fetchNextPage(final String projectName, - final String zoneName, - final ListOptions options) { + @Override protected Function<Object, IterableWithMarker<Disk>> fetchNextPage(final String projectName, + final String zoneName, final ListOptions options) { return new Function<Object, IterableWithMarker<Disk>>() { - @Override - public IterableWithMarker<Disk> apply(Object input) { - return api.getDiskApi(projectName) - .listAtMarkerInZone(zoneName, input.toString(), options); + @Override public IterableWithMarker<Disk> apply(Object input) { + ListPage<Disk> result = api.getDiskApi(projectName) + .listAtMarkerInZone(zoneName, input.toString(), options); + return IterableWithMarkers.from(result, result.nextPageToken()); } }; } http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/b41b0d04/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseFirewalls.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseFirewalls.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseFirewalls.java index 8cb7c5f..732ad3f 100644 --- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseFirewalls.java +++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseFirewalls.java @@ -16,11 +16,10 @@ */ package org.jclouds.googlecomputeengine.functions.internal; -import static com.google.common.base.Preconditions.checkNotNull; - import javax.inject.Inject; import org.jclouds.collect.IterableWithMarker; +import org.jclouds.collect.IterableWithMarkers; import org.jclouds.googlecomputeengine.GoogleComputeEngineApi; import org.jclouds.googlecomputeengine.domain.Firewall; import org.jclouds.googlecomputeengine.domain.ListPage; @@ -31,31 +30,27 @@ import org.jclouds.json.Json; import com.google.common.base.Function; import com.google.inject.TypeLiteral; -public class ParseFirewalls extends ParseJson<ListPage<Firewall>> { +public final class ParseFirewalls extends ParseJson<ListPage<Firewall>> { - @Inject - public ParseFirewalls(Json json) { + @Inject ParseFirewalls(Json json) { super(json, new TypeLiteral<ListPage<Firewall>>() { }); } - public static class ToPagedIterable extends BaseToPagedIterable<Firewall, ToPagedIterable> { + public static final class ToPagedIterable extends BaseToPagedIterable<Firewall, ToPagedIterable> { private final GoogleComputeEngineApi api; - @Inject - protected ToPagedIterable(GoogleComputeEngineApi api) { - this.api = checkNotNull(api, "api"); + @Inject ToPagedIterable(GoogleComputeEngineApi api) { + this.api = api; } - @Override - protected Function<Object, IterableWithMarker<Firewall>> fetchNextPage(final String projectName, - final ListOptions options) { + @Override protected Function<Object, IterableWithMarker<Firewall>> fetchNextPage(final String projectName, + final ListOptions options) { return new Function<Object, IterableWithMarker<Firewall>>() { - - @Override - public IterableWithMarker<Firewall> apply(Object input) { - return api.getFirewallApi(projectName).listAtMarker(input.toString(), options); + @Override public IterableWithMarker<Firewall> apply(Object input) { + ListPage<Firewall> result = api.getFirewallApi(projectName).listAtMarker(input.toString(), options); + return IterableWithMarkers.from(result, result.nextPageToken()); } }; } http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/b41b0d04/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseForwardingRules.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseForwardingRules.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseForwardingRules.java index f3d13dd..4805179 100644 --- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseForwardingRules.java +++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseForwardingRules.java @@ -16,9 +16,10 @@ */ package org.jclouds.googlecomputeengine.functions.internal; -import com.google.common.base.Function; -import com.google.inject.TypeLiteral; +import javax.inject.Inject; + import org.jclouds.collect.IterableWithMarker; +import org.jclouds.collect.IterableWithMarkers; import org.jclouds.googlecomputeengine.GoogleComputeEngineApi; import org.jclouds.googlecomputeengine.domain.ForwardingRule; import org.jclouds.googlecomputeengine.domain.ListPage; @@ -26,16 +27,12 @@ import org.jclouds.googlecomputeengine.options.ListOptions; import org.jclouds.http.functions.ParseJson; import org.jclouds.json.Json; -import javax.inject.Inject; -import javax.inject.Singleton; - -import static com.google.common.base.Preconditions.checkNotNull; +import com.google.common.base.Function; +import com.google.inject.TypeLiteral; -@Singleton -public class ParseForwardingRules extends ParseJson<ListPage<ForwardingRule>> { +public final class ParseForwardingRules extends ParseJson<ListPage<ForwardingRule>> { - @Inject - public ParseForwardingRules(Json json) { + @Inject ParseForwardingRules(Json json) { super(json, new TypeLiteral<ListPage<ForwardingRule>>() { }); } @@ -44,20 +41,17 @@ public class ParseForwardingRules extends ParseJson<ListPage<ForwardingRule>> { private final GoogleComputeEngineApi api; - @Inject - protected ToPagedIterable(GoogleComputeEngineApi api) { - this.api = checkNotNull(api, "api"); + @Inject ToPagedIterable(GoogleComputeEngineApi api) { + this.api = api; } - @Override - protected Function<Object, IterableWithMarker<ForwardingRule>> fetchNextPage(final String projectName, - final String regionName, - final ListOptions options) { + @Override protected Function<Object, IterableWithMarker<ForwardingRule>> fetchNextPage(final String projectName, + final String regionName, + final ListOptions options) { return new Function<Object, IterableWithMarker<ForwardingRule>>() { - - @Override - public IterableWithMarker<ForwardingRule> apply(Object input) { - return api.getForwardingRuleApi(projectName, regionName).list(options); + @Override public IterableWithMarker<ForwardingRule> apply(Object input) { + ListPage<ForwardingRule> result = api.getForwardingRuleApi(projectName, regionName).list(options); + return IterableWithMarkers.from(result, result.nextPageToken()); } }; } http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/b41b0d04/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseGlobalOperations.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseGlobalOperations.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseGlobalOperations.java index 3fdf230..9aa079a 100644 --- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseGlobalOperations.java +++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseGlobalOperations.java @@ -16,11 +16,10 @@ */ package org.jclouds.googlecomputeengine.functions.internal; -import static com.google.common.base.Preconditions.checkNotNull; - import javax.inject.Inject; import org.jclouds.collect.IterableWithMarker; +import org.jclouds.collect.IterableWithMarkers; import org.jclouds.googlecomputeengine.GoogleComputeEngineApi; import org.jclouds.googlecomputeengine.domain.ListPage; import org.jclouds.googlecomputeengine.domain.Operation; @@ -31,31 +30,29 @@ import org.jclouds.json.Json; import com.google.common.base.Function; import com.google.inject.TypeLiteral; -public class ParseGlobalOperations extends ParseJson<ListPage<Operation>> { +public final class ParseGlobalOperations extends ParseJson<ListPage<Operation>> { - @Inject - public ParseGlobalOperations(Json json) { + @Inject ParseGlobalOperations(Json json) { super(json, new TypeLiteral<ListPage<Operation>>() { }); } - public static class ToPagedIterable extends BaseToPagedIterable<Operation, ToPagedIterable> { + public static final class ToPagedIterable extends BaseToPagedIterable<Operation, ToPagedIterable> { private final GoogleComputeEngineApi api; - @Inject - protected ToPagedIterable(GoogleComputeEngineApi api) { - this.api = checkNotNull(api, "api"); + @Inject ToPagedIterable(GoogleComputeEngineApi api) { + this.api = api; } @Override protected Function<Object, IterableWithMarker<Operation>> fetchNextPage(final String projectName, - final ListOptions options) { + final ListOptions options) { return new Function<Object, IterableWithMarker<Operation>>() { - - @Override - public IterableWithMarker<Operation> apply(Object input) { - return api.getGlobalOperationApi(projectName).listAtMarker(input.toString(), options); + @Override public IterableWithMarker<Operation> apply(Object input) { + ListPage<Operation> result = api.getGlobalOperationApi(projectName) + .listAtMarker(input.toString(), options); + return IterableWithMarkers.from(result, result.nextPageToken()); } }; } http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/b41b0d04/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseHttpHealthChecks.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseHttpHealthChecks.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseHttpHealthChecks.java index 5ddc8d9..1027c1f 100644 --- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseHttpHealthChecks.java +++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseHttpHealthChecks.java @@ -16,9 +16,12 @@ */ package org.jclouds.googlecomputeengine.functions.internal; -import com.google.common.base.Function; -import com.google.inject.TypeLiteral; +import static com.google.common.base.Preconditions.checkNotNull; + +import javax.inject.Inject; + import org.jclouds.collect.IterableWithMarker; +import org.jclouds.collect.IterableWithMarkers; import org.jclouds.googlecomputeengine.GoogleComputeEngineApi; import org.jclouds.googlecomputeengine.domain.HttpHealthCheck; import org.jclouds.googlecomputeengine.domain.ListPage; @@ -26,16 +29,12 @@ import org.jclouds.googlecomputeengine.options.ListOptions; import org.jclouds.http.functions.ParseJson; import org.jclouds.json.Json; -import javax.inject.Inject; -import javax.inject.Singleton; - -import static com.google.common.base.Preconditions.checkNotNull; +import com.google.common.base.Function; +import com.google.inject.TypeLiteral; -@Singleton -public class ParseHttpHealthChecks extends ParseJson<ListPage<HttpHealthCheck>> { +public final class ParseHttpHealthChecks extends ParseJson<ListPage<HttpHealthCheck>> { - @Inject - public ParseHttpHealthChecks(Json json) { + @Inject ParseHttpHealthChecks(Json json) { super(json, new TypeLiteral<ListPage<HttpHealthCheck>>() { }); } @@ -44,19 +43,17 @@ public class ParseHttpHealthChecks extends ParseJson<ListPage<HttpHealthCheck>> private final GoogleComputeEngineApi api; - @Inject - protected ToPagedIterable(GoogleComputeEngineApi api) { + @Inject ToPagedIterable(GoogleComputeEngineApi api) { this.api = checkNotNull(api, "api"); } - @Override - protected Function<Object, IterableWithMarker<HttpHealthCheck>> fetchNextPage(final String projectName, - final ListOptions options) { + @Override protected Function<Object, IterableWithMarker<HttpHealthCheck>> fetchNextPage(final String projectName, + final ListOptions options) { return new Function<Object, IterableWithMarker<HttpHealthCheck>>() { - @Override - public IterableWithMarker<HttpHealthCheck> apply(Object input) { - return api.getHttpHealthCheckApi(projectName).list(options); + @Override public IterableWithMarker<HttpHealthCheck> apply(Object input) { + ListPage<HttpHealthCheck> result = api.getHttpHealthCheckApi(projectName).list(options); + return IterableWithMarkers.from(result, result.nextPageToken()); } }; } http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/b41b0d04/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseImages.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseImages.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseImages.java index 102d07b..6bd1e16 100644 --- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseImages.java +++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseImages.java @@ -16,11 +16,10 @@ */ package org.jclouds.googlecomputeengine.functions.internal; -import static com.google.common.base.Preconditions.checkNotNull; - import javax.inject.Inject; import org.jclouds.collect.IterableWithMarker; +import org.jclouds.collect.IterableWithMarkers; import org.jclouds.googlecomputeengine.GoogleComputeEngineApi; import org.jclouds.googlecomputeengine.domain.Image; import org.jclouds.googlecomputeengine.domain.ListPage; @@ -31,31 +30,27 @@ import org.jclouds.json.Json; import com.google.common.base.Function; import com.google.inject.TypeLiteral; -public class ParseImages extends ParseJson<ListPage<Image>> { +public final class ParseImages extends ParseJson<ListPage<Image>> { - @Inject - public ParseImages(Json json) { + @Inject ParseImages(Json json) { super(json, new TypeLiteral<ListPage<Image>>() { }); } - public static class ToPagedIterable extends BaseToPagedIterable<Image, ToPagedIterable> { + public static final class ToPagedIterable extends BaseToPagedIterable<Image, ToPagedIterable> { private final GoogleComputeEngineApi api; - @Inject - protected ToPagedIterable(GoogleComputeEngineApi api) { - this.api = checkNotNull(api, "api"); + @Inject ToPagedIterable(GoogleComputeEngineApi api) { + this.api = api; } - @Override - protected Function<Object, IterableWithMarker<Image>> fetchNextPage(final String projectName, - final ListOptions options) { + @Override protected Function<Object, IterableWithMarker<Image>> fetchNextPage(final String projectName, + final ListOptions options) { return new Function<Object, IterableWithMarker<Image>>() { - - @Override - public IterableWithMarker<Image> apply(Object input) { - return api.getImageApi(projectName).listAtMarker(input.toString(), options); + @Override public IterableWithMarker<Image> apply(Object input) { + ListPage<Image> result = api.getImageApi(projectName).listAtMarker(input.toString(), options); + return IterableWithMarkers.from(result, result.nextPageToken()); } }; } http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/b41b0d04/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseInstances.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseInstances.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseInstances.java index 356ca45..adf0546 100644 --- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseInstances.java +++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseInstances.java @@ -16,11 +16,10 @@ */ package org.jclouds.googlecomputeengine.functions.internal; -import static com.google.common.base.Preconditions.checkNotNull; - import javax.inject.Inject; import org.jclouds.collect.IterableWithMarker; +import org.jclouds.collect.IterableWithMarkers; import org.jclouds.googlecomputeengine.GoogleComputeEngineApi; import org.jclouds.googlecomputeengine.domain.Instance; import org.jclouds.googlecomputeengine.domain.ListPage; @@ -31,33 +30,29 @@ import org.jclouds.json.Json; import com.google.common.base.Function; import com.google.inject.TypeLiteral; -public class ParseInstances extends ParseJson<ListPage<Instance>> { +public final class ParseInstances extends ParseJson<ListPage<Instance>> { - @Inject - public ParseInstances(Json json) { + @Inject ParseInstances(Json json) { super(json, new TypeLiteral<ListPage<Instance>>() { }); } - public static class ToPagedIterable extends BaseWithZoneToPagedIterable<Instance, ToPagedIterable> { + public static final class ToPagedIterable extends BaseWithZoneToPagedIterable<Instance, ToPagedIterable> { private final GoogleComputeEngineApi api; - @Inject - protected ToPagedIterable(GoogleComputeEngineApi api) { - this.api = checkNotNull(api, "api"); + @Inject ToPagedIterable(GoogleComputeEngineApi api) { + this.api = api; } @Override - protected Function<Object, IterableWithMarker<Instance>> fetchNextPage(final String project, - final String zone, - final ListOptions options) { + protected Function<Object, IterableWithMarker<Instance>> fetchNextPage(final String project, final String zone, + final ListOptions options) { return new Function<Object, IterableWithMarker<Instance>>() { - - @Override - public IterableWithMarker<Instance> apply(Object input) { - return api.getInstanceApi(project) - .listAtMarkerInZone(zone, input.toString(), options); + @Override public IterableWithMarker<Instance> apply(Object input) { + ListPage<Instance> result = api.getInstanceApi(project) + .listAtMarkerInZone(zone, input.toString(), options); + return IterableWithMarkers.from(result, result.nextPageToken()); } }; } http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/b41b0d04/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseMachineTypes.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseMachineTypes.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseMachineTypes.java index 0e53257..54111fb 100644 --- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseMachineTypes.java +++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseMachineTypes.java @@ -16,11 +16,10 @@ */ package org.jclouds.googlecomputeengine.functions.internal; -import static com.google.common.base.Preconditions.checkNotNull; - import javax.inject.Inject; import org.jclouds.collect.IterableWithMarker; +import org.jclouds.collect.IterableWithMarkers; import org.jclouds.googlecomputeengine.GoogleComputeEngineApi; import org.jclouds.googlecomputeengine.domain.ListPage; import org.jclouds.googlecomputeengine.domain.MachineType; @@ -31,32 +30,29 @@ import org.jclouds.json.Json; import com.google.common.base.Function; import com.google.inject.TypeLiteral; -public class ParseMachineTypes extends ParseJson<ListPage<MachineType>> { +public final class ParseMachineTypes extends ParseJson<ListPage<MachineType>> { - @Inject - public ParseMachineTypes(Json json) { - super(json, new TypeLiteral<ListPage<MachineType>>() {}); + @Inject ParseMachineTypes(Json json) { + super(json, new TypeLiteral<ListPage<MachineType>>() { + }); } public static class ToPagedIterable extends BaseWithZoneToPagedIterable<MachineType, ToPagedIterable> { private final GoogleComputeEngineApi api; - @Inject - protected ToPagedIterable(GoogleComputeEngineApi api) { - this.api = checkNotNull(api, "api"); + @Inject ToPagedIterable(GoogleComputeEngineApi api) { + this.api = api; } - @Override - protected Function<Object, IterableWithMarker<MachineType>> fetchNextPage(final String project, - final String zone, - final ListOptions options) { + @Override protected Function<Object, IterableWithMarker<MachineType>> fetchNextPage(final String projectName, + final String zoneName, final ListOptions options) { return new Function<Object, IterableWithMarker<MachineType>>() { - @Override - public IterableWithMarker<MachineType> apply(Object input) { - return api.getMachineTypeApi(project) - .listAtMarkerInZone(zone, input.toString(), options); + @Override public IterableWithMarker<MachineType> apply(Object input) { + ListPage<MachineType> result = api.getMachineTypeApi(projectName) + .listAtMarkerInZone(zoneName, input.toString(), options); + return IterableWithMarkers.from(result, result.nextPageToken()); } }; } http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/b41b0d04/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseNetworks.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseNetworks.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseNetworks.java index 62603aa..f3249bb 100644 --- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseNetworks.java +++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseNetworks.java @@ -16,11 +16,10 @@ */ package org.jclouds.googlecomputeengine.functions.internal; -import static com.google.common.base.Preconditions.checkNotNull; - import javax.inject.Inject; import org.jclouds.collect.IterableWithMarker; +import org.jclouds.collect.IterableWithMarkers; import org.jclouds.googlecomputeengine.GoogleComputeEngineApi; import org.jclouds.googlecomputeengine.domain.ListPage; import org.jclouds.googlecomputeengine.domain.Network; @@ -31,31 +30,27 @@ import org.jclouds.json.Json; import com.google.common.base.Function; import com.google.inject.TypeLiteral; -public class ParseNetworks extends ParseJson<ListPage<Network>> { +public final class ParseNetworks extends ParseJson<ListPage<Network>> { - @Inject - public ParseNetworks(Json json) { + @Inject ParseNetworks(Json json) { super(json, new TypeLiteral<ListPage<Network>>() { }); } - public static class ToPagedIterable extends BaseToPagedIterable<Network, ToPagedIterable> { + public static final class ToPagedIterable extends BaseToPagedIterable<Network, ToPagedIterable> { private final GoogleComputeEngineApi api; - @Inject - protected ToPagedIterable(GoogleComputeEngineApi api) { - this.api = checkNotNull(api, "api"); + @Inject ToPagedIterable(GoogleComputeEngineApi api) { + this.api = api; } - @Override - protected Function<Object, IterableWithMarker<Network>> fetchNextPage(final String projectName, - final ListOptions options) { + @Override protected Function<Object, IterableWithMarker<Network>> fetchNextPage(final String projectName, + final ListOptions options) { return new Function<Object, IterableWithMarker<Network>>() { - - @Override - public IterableWithMarker<Network> apply(Object input) { - return api.getNetworkApi(projectName).listAtMarker(input.toString(), options); + @Override public IterableWithMarker<Network> apply(Object input) { + ListPage<Network> result = api.getNetworkApi(projectName).listAtMarker(input.toString(), options); + return IterableWithMarkers.from(result, result.nextPageToken()); } }; } http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/b41b0d04/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseRegionOperations.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseRegionOperations.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseRegionOperations.java index d5fcbfb..a8897d1 100644 --- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseRegionOperations.java +++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseRegionOperations.java @@ -16,11 +16,10 @@ */ package org.jclouds.googlecomputeengine.functions.internal; -import static com.google.common.base.Preconditions.checkNotNull; - import javax.inject.Inject; import org.jclouds.collect.IterableWithMarker; +import org.jclouds.collect.IterableWithMarkers; import org.jclouds.googlecomputeengine.GoogleComputeEngineApi; import org.jclouds.googlecomputeengine.domain.ListPage; import org.jclouds.googlecomputeengine.domain.Operation; @@ -31,10 +30,9 @@ import org.jclouds.json.Json; import com.google.common.base.Function; import com.google.inject.TypeLiteral; -public class ParseRegionOperations extends ParseJson<ListPage<Operation>> { +public final class ParseRegionOperations extends ParseJson<ListPage<Operation>> { - @Inject - public ParseRegionOperations(Json json) { + @Inject ParseRegionOperations(Json json) { super(json, new TypeLiteral<ListPage<Operation>>() { }); } @@ -43,21 +41,17 @@ public class ParseRegionOperations extends ParseJson<ListPage<Operation>> { private final GoogleComputeEngineApi api; - @Inject - protected ToPagedIterable(GoogleComputeEngineApi api) { - this.api = checkNotNull(api, "api"); + @Inject ToPagedIterable(GoogleComputeEngineApi api) { + this.api = api; } - @Override - protected Function<Object, IterableWithMarker<Operation>> fetchNextPage(final String projectName, - final String regionName, - final ListOptions options) { + @Override protected Function<Object, IterableWithMarker<Operation>> fetchNextPage(final String projectName, + final String regionName, final ListOptions options) { return new Function<Object, IterableWithMarker<Operation>>() { - - @Override - public IterableWithMarker<Operation> apply(Object input) { - return api.getRegionOperationApi(projectName) - .listAtMarkerInRegion(regionName, input.toString(), options); + @Override public IterableWithMarker<Operation> apply(Object input) { + ListPage<Operation> result = api.getRegionOperationApi(projectName) + .listAtMarkerInRegion(regionName, input.toString(), options); + return IterableWithMarkers.from(result, result.nextPageToken()); } }; } http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/b41b0d04/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseRegions.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseRegions.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseRegions.java index 6680413..2c7e68b 100644 --- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseRegions.java +++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseRegions.java @@ -16,11 +16,10 @@ */ package org.jclouds.googlecomputeengine.functions.internal; -import static com.google.common.base.Preconditions.checkNotNull; - import javax.inject.Inject; import org.jclouds.collect.IterableWithMarker; +import org.jclouds.collect.IterableWithMarkers; import org.jclouds.googlecomputeengine.GoogleComputeEngineApi; import org.jclouds.googlecomputeengine.domain.ListPage; import org.jclouds.googlecomputeengine.domain.Region; @@ -31,31 +30,27 @@ import org.jclouds.json.Json; import com.google.common.base.Function; import com.google.inject.TypeLiteral; -public class ParseRegions extends ParseJson<ListPage<Region>> { +public final class ParseRegions extends ParseJson<ListPage<Region>> { - @Inject - public ParseRegions(Json json) { + @Inject ParseRegions(Json json) { super(json, new TypeLiteral<ListPage<Region>>() { }); } - public static class ToPagedIterable extends BaseToPagedIterable<Region, ToPagedIterable> { + public static final class ToPagedIterable extends BaseToPagedIterable<Region, ToPagedIterable> { private final GoogleComputeEngineApi api; - @Inject - protected ToPagedIterable(GoogleComputeEngineApi api) { - this.api = checkNotNull(api, "api"); + @Inject ToPagedIterable(GoogleComputeEngineApi api) { + this.api = api; } - @Override - protected Function<Object, IterableWithMarker<Region>> fetchNextPage(final String projectName, - final ListOptions options) { + @Override protected Function<Object, IterableWithMarker<Region>> fetchNextPage(final String projectName, + final ListOptions options) { return new Function<Object, IterableWithMarker<Region>>() { - - @Override - public IterableWithMarker<Region> apply(Object input) { - return api.getRegionApi(projectName).listAtMarker(input.toString(), options); + @Override public IterableWithMarker<Region> apply(Object input) { + ListPage<Region> result = api.getRegionApi(projectName).listAtMarker(input.toString(), options); + return IterableWithMarkers.from(result, result.nextPageToken()); } }; } http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/b41b0d04/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseRoutes.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseRoutes.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseRoutes.java index 8d40984..4f46dc6 100644 --- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseRoutes.java +++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseRoutes.java @@ -16,11 +16,10 @@ */ package org.jclouds.googlecomputeengine.functions.internal; -import static com.google.common.base.Preconditions.checkNotNull; - import javax.inject.Inject; import org.jclouds.collect.IterableWithMarker; +import org.jclouds.collect.IterableWithMarkers; import org.jclouds.googlecomputeengine.GoogleComputeEngineApi; import org.jclouds.googlecomputeengine.domain.ListPage; import org.jclouds.googlecomputeengine.domain.Route; @@ -31,31 +30,28 @@ import org.jclouds.json.Json; import com.google.common.base.Function; import com.google.inject.TypeLiteral; -public class ParseRoutes extends ParseJson<ListPage<Route>> { +public final class ParseRoutes extends ParseJson<ListPage<Route>> { - @Inject - public ParseRoutes(Json json) { + @Inject ParseRoutes(Json json) { super(json, new TypeLiteral<ListPage<Route>>() { }); } - public static class ToPagedIterable extends BaseToPagedIterable<Route, ToPagedIterable> { + public static final class ToPagedIterable extends BaseToPagedIterable<Route, ToPagedIterable> { private final GoogleComputeEngineApi api; - @Inject - protected ToPagedIterable(GoogleComputeEngineApi api) { - this.api = checkNotNull(api, "api"); + @Inject ToPagedIterable(GoogleComputeEngineApi api) { + this.api = api; } @Override protected Function<Object, IterableWithMarker<Route>> fetchNextPage(final String projectName, - final ListOptions options) { + final ListOptions options) { return new Function<Object, IterableWithMarker<Route>>() { - - @Override - public IterableWithMarker<Route> apply(Object input) { - return api.getRouteApi(projectName).listAtMarker(input.toString(), options); + @Override public IterableWithMarker<Route> apply(Object input) { + ListPage<Route> result = api.getRouteApi(projectName).listAtMarker(input.toString(), options); + return IterableWithMarkers.from(result, result.nextPageToken()); } }; } http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/b41b0d04/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseSnapshots.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseSnapshots.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseSnapshots.java index c778ad5..ab7309d 100644 --- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseSnapshots.java +++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseSnapshots.java @@ -16,12 +16,10 @@ */ package org.jclouds.googlecomputeengine.functions.internal; -import static com.google.common.base.Preconditions.checkNotNull; - import javax.inject.Inject; -import javax.inject.Singleton; import org.jclouds.collect.IterableWithMarker; +import org.jclouds.collect.IterableWithMarkers; import org.jclouds.googlecomputeengine.GoogleComputeEngineApi; import org.jclouds.googlecomputeengine.domain.ListPage; import org.jclouds.googlecomputeengine.domain.Snapshot; @@ -32,33 +30,27 @@ import org.jclouds.json.Json; import com.google.common.base.Function; import com.google.inject.TypeLiteral; -@Singleton -public class ParseSnapshots extends ParseJson<ListPage<Snapshot>> { +public final class ParseSnapshots extends ParseJson<ListPage<Snapshot>> { - @Inject - public ParseSnapshots(Json json) { + @Inject ParseSnapshots(Json json) { super(json, new TypeLiteral<ListPage<Snapshot>>() { }); } - public static class ToPagedIterable extends BaseToPagedIterable<Snapshot, ToPagedIterable> { + public static final class ToPagedIterable extends BaseToPagedIterable<Snapshot, ToPagedIterable> { private final GoogleComputeEngineApi api; - @Inject - protected ToPagedIterable(GoogleComputeEngineApi api) { - this.api = checkNotNull(api, "api"); + @Inject ToPagedIterable(GoogleComputeEngineApi api) { + this.api = api; } - @Override - protected Function<Object, IterableWithMarker<Snapshot>> fetchNextPage(final String projectName, - final ListOptions options) { + @Override protected Function<Object, IterableWithMarker<Snapshot>> fetchNextPage(final String projectName, + final ListOptions options) { return new Function<Object, IterableWithMarker<Snapshot>>() { - - @Override - public IterableWithMarker<Snapshot> apply(Object input) { - return api.getSnapshotApi(projectName) - .listAtMarker(input.toString(), options); + @Override public IterableWithMarker<Snapshot> apply(Object input) { + ListPage<Snapshot> result = api.getSnapshotApi(projectName).listAtMarker(input.toString(), options); + return IterableWithMarkers.from(result, result.nextPageToken()); } }; } http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/b41b0d04/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseTargetPools.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseTargetPools.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseTargetPools.java index 2f19ca2..80e4194 100644 --- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseTargetPools.java +++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseTargetPools.java @@ -16,9 +16,12 @@ */ package org.jclouds.googlecomputeengine.functions.internal; -import com.google.common.base.Function; -import com.google.inject.TypeLiteral; +import static com.google.common.base.Preconditions.checkNotNull; + +import javax.inject.Inject; + import org.jclouds.collect.IterableWithMarker; +import org.jclouds.collect.IterableWithMarkers; import org.jclouds.googlecomputeengine.GoogleComputeEngineApi; import org.jclouds.googlecomputeengine.domain.ListPage; import org.jclouds.googlecomputeengine.domain.TargetPool; @@ -26,16 +29,12 @@ import org.jclouds.googlecomputeengine.options.ListOptions; import org.jclouds.http.functions.ParseJson; import org.jclouds.json.Json; -import javax.inject.Inject; -import javax.inject.Singleton; - -import static com.google.common.base.Preconditions.checkNotNull; +import com.google.common.base.Function; +import com.google.inject.TypeLiteral; -@Singleton -public class ParseTargetPools extends ParseJson<ListPage<TargetPool>> { +public final class ParseTargetPools extends ParseJson<ListPage<TargetPool>> { - @Inject - public ParseTargetPools(Json json) { + @Inject ParseTargetPools(Json json) { super(json, new TypeLiteral<ListPage<TargetPool>>() { }); } @@ -44,21 +43,19 @@ public class ParseTargetPools extends ParseJson<ListPage<TargetPool>> { private final GoogleComputeEngineApi api; - @Inject - protected ToPagedIterable(GoogleComputeEngineApi api) { + @Inject ToPagedIterable(GoogleComputeEngineApi api) { this.api = checkNotNull(api, "api"); } - @Override - protected Function<Object, IterableWithMarker<TargetPool>> fetchNextPage(final String projectName, + @Override protected Function<Object, IterableWithMarker<TargetPool>> fetchNextPage(final String projectName, final String regionName, final ListOptions options) { return new Function<Object, IterableWithMarker<TargetPool>>() { @Override public IterableWithMarker<TargetPool> apply(Object input) { - return api.getTargetPoolApi(projectName, regionName) - .list(options); + ListPage<TargetPool> result = api.getTargetPoolApi(projectName, regionName).list(options); + return IterableWithMarkers.from(result, result.nextPageToken()); } }; } http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/b41b0d04/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseZoneOperations.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseZoneOperations.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseZoneOperations.java index 1d0adbd..3019f7d 100644 --- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseZoneOperations.java +++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseZoneOperations.java @@ -16,11 +16,10 @@ */ package org.jclouds.googlecomputeengine.functions.internal; -import static com.google.common.base.Preconditions.checkNotNull; - import javax.inject.Inject; import org.jclouds.collect.IterableWithMarker; +import org.jclouds.collect.IterableWithMarkers; import org.jclouds.googlecomputeengine.GoogleComputeEngineApi; import org.jclouds.googlecomputeengine.domain.ListPage; import org.jclouds.googlecomputeengine.domain.Operation; @@ -31,10 +30,9 @@ import org.jclouds.json.Json; import com.google.common.base.Function; import com.google.inject.TypeLiteral; -public class ParseZoneOperations extends ParseJson<ListPage<Operation>> { +public final class ParseZoneOperations extends ParseJson<ListPage<Operation>> { - @Inject - public ParseZoneOperations(Json json) { + @Inject ParseZoneOperations(Json json) { super(json, new TypeLiteral<ListPage<Operation>>() { }); } @@ -43,21 +41,18 @@ public class ParseZoneOperations extends ParseJson<ListPage<Operation>> { private final GoogleComputeEngineApi api; - @Inject - protected ToPagedIterable(GoogleComputeEngineApi api) { - this.api = checkNotNull(api, "api"); + @Inject ToPagedIterable(GoogleComputeEngineApi api) { + this.api = api; } - @Override - protected Function<Object, IterableWithMarker<Operation>> fetchNextPage(final String projectName, - final String zoneName, - final ListOptions options) { + @Override protected Function<Object, IterableWithMarker<Operation>> fetchNextPage(final String projectName, + final String zoneName, final ListOptions options) { return new Function<Object, IterableWithMarker<Operation>>() { - @Override - public IterableWithMarker<Operation> apply(Object input) { - return api.getZoneOperationApi(projectName) - .listAtMarkerInZone(zoneName, input.toString(), options); + @Override public IterableWithMarker<Operation> apply(Object input) { + ListPage<Operation> result = api.getZoneOperationApi(projectName) + .listAtMarkerInZone(zoneName, input.toString(), options); + return IterableWithMarkers.from(result, result.nextPageToken()); } }; } http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/b41b0d04/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseZones.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseZones.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseZones.java index 0d474d6..24e925e 100644 --- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseZones.java +++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseZones.java @@ -16,11 +16,10 @@ */ package org.jclouds.googlecomputeengine.functions.internal; -import static com.google.common.base.Preconditions.checkNotNull; - import javax.inject.Inject; import org.jclouds.collect.IterableWithMarker; +import org.jclouds.collect.IterableWithMarkers; import org.jclouds.googlecomputeengine.GoogleComputeEngineApi; import org.jclouds.googlecomputeengine.domain.ListPage; import org.jclouds.googlecomputeengine.domain.Zone; @@ -31,31 +30,28 @@ import org.jclouds.json.Json; import com.google.common.base.Function; import com.google.inject.TypeLiteral; -public class ParseZones extends ParseJson<ListPage<Zone>> { +public final class ParseZones extends ParseJson<ListPage<Zone>> { - @Inject - public ParseZones(Json json) { + @Inject ParseZones(Json json) { super(json, new TypeLiteral<ListPage<Zone>>() { }); } - public static class ToPagedIterable extends BaseToPagedIterable<Zone, ToPagedIterable> { + public static final class ToPagedIterable extends BaseToPagedIterable<Zone, ToPagedIterable> { private final GoogleComputeEngineApi api; - @Inject - protected ToPagedIterable(GoogleComputeEngineApi api) { - this.api = checkNotNull(api, "api"); + @Inject ToPagedIterable(GoogleComputeEngineApi api) { + this.api = api; } @Override protected Function<Object, IterableWithMarker<Zone>> fetchNextPage(final String projectName, - final ListOptions options) { + final ListOptions options) { return new Function<Object, IterableWithMarker<Zone>>() { - - @Override - public IterableWithMarker<Zone> apply(Object input) { - return api.getZoneApi(projectName).listAtMarker(input.toString(), options); + @Override public IterableWithMarker<Zone> apply(Object input) { + ListPage<Zone> result = api.getZoneApi(projectName).listAtMarker(input.toString(), options); + return IterableWithMarkers.from(result, result.nextPageToken()); } }; } http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/b41b0d04/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/internal/NullSafeCopies.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/internal/NullSafeCopies.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/internal/NullSafeCopies.java new file mode 100644 index 0000000..3e5c961 --- /dev/null +++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/internal/NullSafeCopies.java @@ -0,0 +1,39 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.googlecomputeengine.internal; + +import java.util.List; +import java.util.Map; + +import org.jclouds.javax.annotation.Nullable; + +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; + +public final class NullSafeCopies { + + public static <K, V> Map<K, V> copyOf(@Nullable Map<K, V> map) { + return map != null ? ImmutableMap.copyOf(map) : ImmutableMap.<K, V>of(); + } + + public static <E> List<E> copyOf(@Nullable List<E> list) { + return list != null ? ImmutableList.copyOf(list) : ImmutableList.<E>of(); + } + + private NullSafeCopies() { + } +} http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/b41b0d04/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/options/FirewallOptions.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/options/FirewallOptions.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/options/FirewallOptions.java index 300ce53..0762e96 100644 --- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/options/FirewallOptions.java +++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/options/FirewallOptions.java @@ -17,11 +17,11 @@ package org.jclouds.googlecomputeengine.options; import java.net.URI; -import java.util.Set; +import java.util.List; import org.jclouds.googlecomputeengine.domain.Firewall; -import com.google.common.collect.ImmutableSet; +import com.google.common.collect.ImmutableList; /** * Options to insert a firewall. @@ -32,20 +32,20 @@ public class FirewallOptions { private String name; private URI network; - private ImmutableSet.Builder<String> sourceRanges = ImmutableSet.builder(); - private ImmutableSet.Builder<String> sourceTags = ImmutableSet.builder(); - private ImmutableSet.Builder<String> targetTags = ImmutableSet.builder(); - private ImmutableSet.Builder<Firewall.Rule> allowed = ImmutableSet.builder(); + private ImmutableList.Builder<String> sourceRanges = ImmutableList.builder(); + private ImmutableList.Builder<String> sourceTags = ImmutableList.builder(); + private ImmutableList.Builder<String> targetTags = ImmutableList.builder(); + private ImmutableList.Builder<Firewall.Rule> allowed = ImmutableList.builder(); /** - * @see org.jclouds.googlecomputeengine.domain.Firewall#getAllowed() + * @see org.jclouds.googlecomputeengine.domain.Firewall#allowed() */ - public Set<Firewall.Rule> getAllowed() { + public List<Firewall.Rule> getAllowed() { return allowed.build(); } /** - * @see org.jclouds.googlecomputeengine.domain.Firewall#getAllowed() + * @see org.jclouds.googlecomputeengine.domain.Firewall#allowed() */ public FirewallOptions addAllowedRule(Firewall.Rule allowedRule) { this.allowed.add(allowedRule); @@ -53,16 +53,16 @@ public class FirewallOptions { } /** - * @see org.jclouds.googlecomputeengine.domain.Firewall#getAllowed() + * @see org.jclouds.googlecomputeengine.domain.Firewall#allowed() */ - public FirewallOptions allowedRules(Set<Firewall.Rule> allowedRules) { - this.allowed = ImmutableSet.builder(); + public FirewallOptions allowedRules(List<Firewall.Rule> allowedRules) { + this.allowed = ImmutableList.builder(); this.allowed.addAll(allowedRules); return this; } /** - * @see org.jclouds.googlecomputeengine.domain.Firewall#getName() + * @see org.jclouds.googlecomputeengine.domain.Firewall#name() */ public FirewallOptions name(String name) { this.name = name; @@ -70,14 +70,14 @@ public class FirewallOptions { } /** - * @see org.jclouds.googlecomputeengine.domain.Firewall#getName() + * @see org.jclouds.googlecomputeengine.domain.Firewall#name() */ - public String getName() { + public String name() { return name; } /** - * @see org.jclouds.googlecomputeengine.domain.Firewall#getNetwork() + * @see org.jclouds.googlecomputeengine.domain.Firewall#network() */ public FirewallOptions network(URI network) { this.network = network; @@ -85,21 +85,21 @@ public class FirewallOptions { } /** - * @see org.jclouds.googlecomputeengine.domain.Firewall#getNetwork() + * @see org.jclouds.googlecomputeengine.domain.Firewall#network() */ - public URI getNetwork() { + public URI network() { return network; } /** - * @see org.jclouds.googlecomputeengine.domain.Firewall#getSourceRanges() + * @see org.jclouds.googlecomputeengine.domain.Firewall#sourceRanges() */ - public Set<String> getSourceRanges() { + public List<String> sourceRanges() { return sourceRanges.build(); } /** - * @see org.jclouds.googlecomputeengine.domain.Firewall#getSourceRanges() + * @see org.jclouds.googlecomputeengine.domain.Firewall#sourceRanges() */ public FirewallOptions addSourceRange(String sourceRange) { this.sourceRanges.add(sourceRange); @@ -107,23 +107,23 @@ public class FirewallOptions { } /** - * @see org.jclouds.googlecomputeengine.domain.Firewall#getSourceRanges() + * @see org.jclouds.googlecomputeengine.domain.Firewall#sourceRanges() */ - public FirewallOptions sourceRanges(Set<String> sourceRanges) { - this.sourceRanges = ImmutableSet.builder(); + public FirewallOptions sourceRanges(Iterable<String> sourceRanges) { + this.sourceRanges = ImmutableList.builder(); this.sourceRanges.addAll(sourceRanges); return this; } /** - * @see org.jclouds.googlecomputeengine.domain.Firewall#getSourceTags() + * @see org.jclouds.googlecomputeengine.domain.Firewall#sourceTags() */ - public Set<String> getSourceTags() { + public List<String> sourceTags() { return sourceTags.build(); } /** - * @see org.jclouds.googlecomputeengine.domain.Firewall#getSourceTags() + * @see org.jclouds.googlecomputeengine.domain.Firewall#sourceTags() */ public FirewallOptions addSourceTag(String sourceTag) { this.sourceTags.add(sourceTag); @@ -131,23 +131,23 @@ public class FirewallOptions { } /** - * @see org.jclouds.googlecomputeengine.domain.Firewall#getSourceTags() + * @see org.jclouds.googlecomputeengine.domain.Firewall#sourceTags() */ - public FirewallOptions sourceTags(Set<String> sourceTags) { - this.sourceTags = ImmutableSet.builder(); + public FirewallOptions sourceTags(Iterable<String> sourceTags) { + this.sourceTags = ImmutableList.builder(); this.sourceTags.addAll(sourceTags); return this; } /** - * @see org.jclouds.googlecomputeengine.domain.Firewall#getTargetTags() + * @see org.jclouds.googlecomputeengine.domain.Firewall#targetTags() */ - public Set<String> getTargetTags() { + public List<String> targetTags() { return targetTags.build(); } /** - * @see org.jclouds.googlecomputeengine.domain.Firewall#getTargetTags() + * @see org.jclouds.googlecomputeengine.domain.Firewall#targetTags() */ public FirewallOptions addTargetTag(String targetTag) { this.targetTags.add(targetTag); @@ -155,12 +155,12 @@ public class FirewallOptions { } /** - * @see org.jclouds.googlecomputeengine.domain.Firewall#getTargetTags() + * @see org.jclouds.googlecomputeengine.domain.Firewall#targetTags() */ - public FirewallOptions targetTags(Set<String> targetTags) { - this.targetTags = ImmutableSet.builder(); + public FirewallOptions targetTags(List<String> targetTags) { + this.targetTags = ImmutableList.builder(); this.targetTags.addAll(targetTags); return this; } - } + http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/b41b0d04/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/options/ForwardingRuleCreationOptions.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/options/ForwardingRuleCreationOptions.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/options/ForwardingRuleCreationOptions.java index 166566a..1594cee 100644 --- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/options/ForwardingRuleCreationOptions.java +++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/options/ForwardingRuleCreationOptions.java @@ -18,7 +18,7 @@ package org.jclouds.googlecomputeengine.options; import java.net.URI; -import org.jclouds.googlecomputeengine.domain.ForwardingRule.IPProtocolOption; +import org.jclouds.googlecomputeengine.domain.ForwardingRule; /** * Options for creating a Forwarding Rule @@ -27,7 +27,7 @@ public class ForwardingRuleCreationOptions{ private String description; private String ipAddress; - private IPProtocolOption ipProtocol; + private ForwardingRule.IPProtocol ipProtocol; private String portRange; private URI target; @@ -51,7 +51,7 @@ public class ForwardingRuleCreationOptions{ * The IP protocol to which this rule applies * @return ipProtocol */ - public IPProtocolOption getIPProtocol(){ + public ForwardingRule.IPProtocol getIPProtocol(){ return ipProtocol; } @@ -92,7 +92,7 @@ public class ForwardingRuleCreationOptions{ /** * @see ForwardingRuleCreationOptions#getIPProtocol() */ - public ForwardingRuleCreationOptions ipProtocol(IPProtocolOption ipProtocol){ + public ForwardingRuleCreationOptions ipProtocol(ForwardingRule.IPProtocol ipProtocol){ this.ipProtocol = ipProtocol; return this; } http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/b41b0d04/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/options/HttpHealthCheckCreationOptions.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/options/HttpHealthCheckCreationOptions.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/options/HttpHealthCheckCreationOptions.java index 3f16f96..705b01b 100644 --- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/options/HttpHealthCheckCreationOptions.java +++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/options/HttpHealthCheckCreationOptions.java @@ -16,9 +16,6 @@ */ package org.jclouds.googlecomputeengine.options; -/** - * Options for creating a Health Check - */ public class HttpHealthCheckCreationOptions { private String host; @@ -34,7 +31,7 @@ public class HttpHealthCheckCreationOptions { * The value of the host header in the HTTP health check request. * @return host */ - public String getHost(){ + public String host(){ return host; } @@ -42,7 +39,7 @@ public class HttpHealthCheckCreationOptions { * The request path of the HTTP health check request. The default value is /. * @return requestPath */ - public String getRequestPath(){ + public String requestPath(){ return requestPath; } @@ -50,7 +47,7 @@ public class HttpHealthCheckCreationOptions { * The TCP port number for the HTTP health check request. The default value is 80. * @return port */ - public Integer getPort(){ + public Integer port(){ return port; } @@ -58,7 +55,7 @@ public class HttpHealthCheckCreationOptions { * How often (in seconds) to send a health check. The default value is 5 seconds. * @return checkIntervalSec */ - public Integer getCheckIntervalSec(){ + public Integer checkIntervalSec(){ return checkIntervalSec; } @@ -66,7 +63,7 @@ public class HttpHealthCheckCreationOptions { * How long (in seconds) to wait before claiming failure. The default value is 5 seconds. * @return timeoutSec */ - public Integer getTimeoutSec(){ + public Integer timeoutSec(){ return timeoutSec; } @@ -75,7 +72,7 @@ public class HttpHealthCheckCreationOptions { * The default value is 2. * @return unhealthyThreashold */ - public Integer getUnhealthyThreshold(){ + public Integer unhealthyThreshold(){ return unhealthyThreshold; } @@ -84,7 +81,7 @@ public class HttpHealthCheckCreationOptions { * The default value is 2. * @return healthyThreashold */ - public Integer getHealthyThreshold(){ + public Integer healthyThreshold(){ return healthyThreshold; } @@ -92,12 +89,12 @@ public class HttpHealthCheckCreationOptions { * An optional textual description of the TargetPool. * @return description, provided by the client. */ - public String getDescription(){ + public String description(){ return description; } /** - * @see HttpHealthCheckCreationOptions#getHost() + * @see HttpHealthCheckCreationOptions#host() */ public HttpHealthCheckCreationOptions host(String host){ this.host = host; @@ -105,7 +102,7 @@ public class HttpHealthCheckCreationOptions { } /** - * @see HttpHealthCheckCreationOptions#getRequestPath() + * @see HttpHealthCheckCreationOptions#requestPath() */ public HttpHealthCheckCreationOptions requestPath(String requestPath){ this.requestPath = requestPath; @@ -113,7 +110,7 @@ public class HttpHealthCheckCreationOptions { } /** - * @see HttpHealthCheckCreationOptions#getPort() + * @see HttpHealthCheckCreationOptions#port() */ public HttpHealthCheckCreationOptions port(Integer port){ this.port = port; @@ -121,7 +118,7 @@ public class HttpHealthCheckCreationOptions { } /** - * @see HttpHealthCheckCreationOptions#getCheckIntervalSec() + * @see HttpHealthCheckCreationOptions#checkIntervalSec() */ public HttpHealthCheckCreationOptions checkIntervalSec(Integer checkIntervalSec){ this.checkIntervalSec = checkIntervalSec; @@ -129,7 +126,7 @@ public class HttpHealthCheckCreationOptions { } /** - * @see HttpHealthCheckCreationOptions#getTimeoutSec() + * @see HttpHealthCheckCreationOptions#timeoutSec() */ public HttpHealthCheckCreationOptions timeoutSec(Integer timeoutSec){ this.timeoutSec = timeoutSec; @@ -137,7 +134,7 @@ public class HttpHealthCheckCreationOptions { } /** - * @see HttpHealthCheckCreationOptions#getUnhealthyThreshold() + * @see HttpHealthCheckCreationOptions#unhealthyThreshold() */ public HttpHealthCheckCreationOptions unhealthyThreshold(Integer unhealthyThreshold){ this.unhealthyThreshold = unhealthyThreshold; @@ -145,7 +142,7 @@ public class HttpHealthCheckCreationOptions { } /** - * @see HttpHealthCheckCreationOptions#getHealthyThreshold() + * @see HttpHealthCheckCreationOptions#healthyThreshold() */ public HttpHealthCheckCreationOptions healthyThreshold(Integer healthyThreshold){ this.healthyThreshold = healthyThreshold; @@ -153,7 +150,7 @@ public class HttpHealthCheckCreationOptions { } /** - * @see HttpHealthCheckCreationOptions#getDescription() + * @see HttpHealthCheckCreationOptions#description() */ public HttpHealthCheckCreationOptions description(String description){ this.description = description; http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/b41b0d04/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/options/RouteOptions.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/options/RouteOptions.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/options/RouteOptions.java index a6fa6ac..98f3f03 100644 --- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/options/RouteOptions.java +++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/options/RouteOptions.java @@ -17,9 +17,9 @@ package org.jclouds.googlecomputeengine.options; import java.net.URI; -import java.util.Set; +import java.util.List; -import com.google.common.collect.ImmutableSet; +import com.google.common.collect.ImmutableList; /** * Options to insert a route. @@ -38,17 +38,17 @@ public class RouteOptions { private String description; private Integer priority; - private ImmutableSet.Builder<String> tags = ImmutableSet.builder(); + private ImmutableList.Builder<String> tags = ImmutableList.builder(); /** - * @see org.jclouds.googlecomputeengine.domain.Route#getName() + * @see org.jclouds.googlecomputeengine.domain.Route#name() */ - public String getName() { + public String name() { return name; } /** - * @see org.jclouds.googlecomputeengine.domain.Route#getName() + * @see org.jclouds.googlecomputeengine.domain.Route#name() */ public RouteOptions name(String name) { this.name = name; @@ -178,7 +178,7 @@ public class RouteOptions { /** * @see org.jclouds.googlecomputeengine.domain.Route#getTags() */ - public Set<String> getTags() { + public List<String> getTags() { return tags.build(); } @@ -193,8 +193,8 @@ public class RouteOptions { /** * @see org.jclouds.googlecomputeengine.domain.Route#getTags() */ - public RouteOptions tags(Set<String> tags) { - this.tags = ImmutableSet.builder(); + public RouteOptions tags(List<String> tags) { + this.tags = ImmutableList.builder(); this.tags.addAll(tags); return this; } http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/b41b0d04/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/options/TargetPoolCreationOptions.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/options/TargetPoolCreationOptions.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/options/TargetPoolCreationOptions.java index e80d721..4864148 100644 --- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/options/TargetPoolCreationOptions.java +++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/options/TargetPoolCreationOptions.java @@ -17,7 +17,7 @@ package org.jclouds.googlecomputeengine.options; import java.net.URI; -import java.util.Set; +import java.util.List; /** * Options for creating a Target Pool @@ -36,8 +36,8 @@ public class TargetPoolCreationOptions{ NONE } - private Set<URI> healthChecks; - private Set<URI> instances; + private List<URI> healthChecks; + private List<URI> instances; private SessionAffinityValue sessionAffinity; private Float failoverRatio; private URI backupPool; @@ -48,17 +48,17 @@ public class TargetPoolCreationOptions{ * * @return a set of HealthCheck URIs */ - public Set<URI> getHealthChecks(){ + public List<URI> getHealthChecks(){ return healthChecks; } /** - * A Set of resource URIs to the member VMs serving this pool. + * A List of resource URIs to the member VMs serving this pool. * They must live in zones contained in the same region as this pool. * * @return set of instance URIs */ - public Set<URI> getInstances(){ + public List<URI> getInstances(){ return instances; } @@ -103,7 +103,7 @@ public class TargetPoolCreationOptions{ /** * @see TargetPoolCreationOptions#getHealthChecks() */ - public TargetPoolCreationOptions healthChecks(Set<URI> healthChecks){ + public TargetPoolCreationOptions healthChecks(List<URI> healthChecks){ this.healthChecks = healthChecks; return this; } @@ -111,7 +111,7 @@ public class TargetPoolCreationOptions{ /** * @see TargetPoolCreationOptions#getInstances() */ - public TargetPoolCreationOptions instances(Set<URI> instances){ + public TargetPoolCreationOptions instances(List<URI> instances){ this.instances = instances; return this; } http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/b41b0d04/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/predicates/GlobalOperationDonePredicate.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/predicates/GlobalOperationDonePredicate.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/predicates/GlobalOperationDonePredicate.java index f7be915..10fb995 100644 --- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/predicates/GlobalOperationDonePredicate.java +++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/predicates/GlobalOperationDonePredicate.java @@ -28,25 +28,20 @@ import com.google.common.base.Predicate; import com.google.common.base.Supplier; import com.google.inject.Inject; -/** - * Tests that a Global Operation is done, returning the completed Operation when it is. - */ -public class GlobalOperationDonePredicate implements Predicate<AtomicReference<Operation>> { +public final class GlobalOperationDonePredicate implements Predicate<AtomicReference<Operation>> { private final GoogleComputeEngineApi api; private final Supplier<String> project; - @Inject - public GlobalOperationDonePredicate(GoogleComputeEngineApi api, @UserProject Supplier<String> project) { + @Inject GlobalOperationDonePredicate(GoogleComputeEngineApi api, @UserProject Supplier<String> project) { this.api = api; this.project = project; } - @Override - public boolean apply(AtomicReference<Operation> input) { + @Override public boolean apply(AtomicReference<Operation> input) { checkNotNull(input, "input"); - Operation current = api.getGlobalOperationApi(project.get()).get(input.get().getName()); - switch (current.getStatus()) { + Operation current = api.getGlobalOperationApi(project.get()).get(input.get().name()); + switch (current.status()) { case DONE: input.set(current); return true; http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/b41b0d04/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/predicates/InstancePredicates.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/predicates/InstancePredicates.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/predicates/InstancePredicates.java index 8cde680..e8d6535 100644 --- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/predicates/InstancePredicates.java +++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/predicates/InstancePredicates.java @@ -16,7 +16,7 @@ */ package org.jclouds.googlecomputeengine.predicates; -import org.jclouds.googlecomputeengine.domain.InstanceTemplate.PersistentDisk; +import org.jclouds.googlecomputeengine.domain.templates.InstanceTemplate.PersistentDisk; import com.google.common.base.Predicate; @@ -26,7 +26,7 @@ public class InstancePredicates { return new Predicate<PersistentDisk>() { @Override public boolean apply(PersistentDisk input) { - return input.isBoot(); + return input.boot(); } }; }
