@Override public Location get() { Set<? extends Location> locations = locationsSupplier.get(); try { return find(locations, isZone()); } catch (NoSuchElementException e) { throw new NoSuchElementException("none to of the locations are scope ZONE: " + transform(locations, ToIdAndScope.INSTANCE)); } }
@Override @Singleton public Location get() { String region = regionSupplier.get(); Predicate<Location> locationPredicate = region == null ? Predicates.<Location>or(isZone(), isRegion()) : isZoneOrRegionWhereRegionIdEquals(region); Set<? extends Location> locations = locationsSupplier.get(); if (locationsSupplier.get().size() == 1) return getOnlyElement(locationsSupplier.get()); try { Location toReturn = Iterables.find(locations, locationPredicate); return toReturn.getScope() == LocationScope.REGION ? toReturn : toReturn.getParent(); } catch (NoSuchElementException e) { throw new NoSuchElementException(String.format("couldn't find region matching %s in %s", locationPredicate, transform(locations, ToIdAndScope.INSTANCE))); } } }
@Override @Singleton public Location get() { String region = regionSupplier.get(); Predicate<Location> locationPredicate = region == null ? Predicates.<Location>or(isZone(), isRegion()) : isZoneOrRegionWhereRegionIdEquals(region); Set<? extends Location> locations = locationsSupplier.get(); if (locationsSupplier.get().size() == 1) return getOnlyElement(locationsSupplier.get()); try { Location toReturn = Iterables.find(locations, locationPredicate); return toReturn.getScope() == LocationScope.REGION ? toReturn : toReturn.getParent(); } catch (NoSuchElementException e) { throw new NoSuchElementException(String.format("couldn't find region matching %s in %s", locationPredicate, transform(locations, ToIdAndScope.INSTANCE))); } } }
@Override public Location get() { Set<? extends Location> locations = locationsSupplier.get(); try { return find(locations, isZone()); } catch (NoSuchElementException e) { throw new NoSuchElementException("none to of the locations are scope ZONE: " + transform(locations, ToIdAndScope.INSTANCE)); } }
@Override @Singleton public Location get() { String region = regionSupplier.get(); Predicate<Location> locationPredicate = region == null ? Predicates.<Location>or(isZone(), isRegion()) : isZoneOrRegionWhereRegionIdEquals(region); Set<? extends Location> locations = locationsSupplier.get(); if (locationsSupplier.get().size() == 1) return getOnlyElement(locationsSupplier.get()); try { Location toReturn = Iterables.find(locations, locationPredicate); return toReturn.getScope() == LocationScope.REGION ? toReturn : toReturn.getParent(); } catch (NoSuchElementException e) { throw new NoSuchElementException(String.format("couldn't find region matching %s in %s", locationPredicate, transform(locations, ToIdAndScope.INSTANCE))); } } }
@Override public Location get() { Set<? extends Location> locations = locationsSupplier.get(); try { return find(locations, isZone()); } catch (NoSuchElementException e) { throw new NoSuchElementException("none to of the locations are scope ZONE: " + transform(locations, ToIdAndScope.INSTANCE)); } }
@Override @Singleton public Location get() { String region = regionSupplier.get(); Predicate<Location> locationPredicate = region == null ? Predicates.<Location>or(isZone(), isRegion()) : isZoneOrRegionWhereRegionIdEquals(region); Set<? extends Location> locations = locationsSupplier.get(); if (locationsSupplier.get().size() == 1) return getOnlyElement(locationsSupplier.get()); try { Location toReturn = Iterables.find(locations, locationPredicate); return toReturn.getScope() == LocationScope.REGION ? toReturn : toReturn.getParent(); } catch (NoSuchElementException e) { throw new NoSuchElementException(String.format("couldn't find region matching %s in %s", locationPredicate, transform(locations, ToIdAndScope.INSTANCE))); } } }
@Override public Location get() { Set<? extends Location> locations = locationsSupplier.get(); try { return find(locations, isZone()); } catch (NoSuchElementException e) { throw new NoSuchElementException("none to of the locations are scope ZONE: " + transform(locations, ToIdAndScope.INSTANCE)); } }
@Override @Singleton public Location get() { String region = regionSupplier.get(); Predicate<Location> locationPredicate = region == null ? Predicates.<Location>or(isZone(), isRegion()) : isZoneOrRegionWhereRegionIdEquals(region); Set<? extends Location> locations = locationsSupplier.get(); if (locationsSupplier.get().size() == 1) return getOnlyElement(locationsSupplier.get()); try { Location toReturn = Iterables.find(locations, locationPredicate); return toReturn.getScope() == LocationScope.REGION ? toReturn : toReturn.getParent(); } catch (NoSuchElementException e) { throw new NoSuchElementException(String.format("couldn't find region matching %s in %s", locationPredicate, transform(locations, ToIdAndScope.INSTANCE))); } } }
@Override public Location get() { Set<? extends Location> locations = locationsSupplier.get(); if (locations.size() == 1) return getOnlyElement(locations); try { return find(locations, isZone()); } catch (NoSuchElementException e) { throw new NoSuchElementException("none to of the locations are scope ZONE: " + transform(locations, ToIdAndScope.INSTANCE)); } }
@Override @Singleton public Location get() { String region = regionSupplier.get(); Predicate<Location> locationPredicate = region == null ? Predicates.<Location>or(isZone(), isRegion()) : isZoneOrRegionWhereRegionIdEquals(region); Set<? extends Location> locations = locationsSupplier.get(); if (locationsSupplier.get().size() == 1) return getOnlyElement(locationsSupplier.get()); try { Location toReturn = Iterables.find(locations, locationPredicate); return toReturn.getScope() == LocationScope.REGION ? toReturn : toReturn.getParent(); } catch (NoSuchElementException e) { throw new NoSuchElementException(String.format("couldn't find region matching %s in %s", locationPredicate, transform(locations, ToIdAndScope.INSTANCE))); } } }
@Override public Location get() { Set<? extends Location> locations = locationsSupplier.get(); try { return find(locations, isZone()); } catch (NoSuchElementException e) { throw new NoSuchElementException("none to of the locations are scope ZONE: " + transform(locations, ToIdAndScope.INSTANCE)); } }
@Override public Location get() { Set<? extends Location> locations = locationsSupplier.get(); if (locations.size() == 1) return getOnlyElement(locations); try { return find(locations, isZone()); } catch (NoSuchElementException e) { throw new NoSuchElementException("none to of the locations are scope ZONE: " + transform(locations, ToIdAndScope.INSTANCE)); } }
@Override public Location get() { Set<? extends Location> locations = locationsSupplier.get(); try { return find(locations, isZone()); } catch (NoSuchElementException e) { throw new NoSuchElementException("none to of the locations are scope ZONE: " + transform(locations, ToIdAndScope.INSTANCE)); } }
@Override public Location get() { Set<? extends Location> locations = locationsSupplier.get(); if (locations.size() == 1) return getOnlyElement(locations); try { return find(locations, isZone()); } catch (NoSuchElementException e) { throw new NoSuchElementException("none to of the locations are scope ZONE: " + transform(locations, ToIdAndScope.INSTANCE)); } }
@Override public Location get() { Set<? extends Location> locations = locationsSupplier.get(); if (locations.size() == 1) return getOnlyElement(locations); try { return find(locations, isZone()); } catch (NoSuchElementException e) { throw new NoSuchElementException("none to of the locations are scope ZONE: " + transform(locations, ToIdAndScope.INSTANCE)); } }
@Override public Location get() { Set<? extends Location> locations = locationsSupplier.get(); if (locations.size() == 1) return getOnlyElement(locations); try { return find(locations, isZone()); } catch (NoSuchElementException e) { throw new NoSuchElementException("none to of the locations are scope ZONE: " + transform(locations, ToIdAndScope.INSTANCE)); } }
@Override public Location get() { Set<? extends Location> locations = locationsSupplier.get(); if (locations.size() == 1) return getOnlyElement(locations); try { return find(locations, isZone()); } catch (NoSuchElementException e) { throw new NoSuchElementException("none to of the locations are scope ZONE: " + transform(locations, ToIdAndScope.INSTANCE)); } }
@Override public Iterable<MachineType> listHardwareProfiles() { // JCLOUDS-1463: Only return the machine types that belong to zones that are actually available final Iterable<String> zones = transform(filter(listLocations(), isZone()), new Function<Location, String>() { public String apply(Location input) { return input.getId(); } }); return filter(concat(api.aggregatedList().machineTypes()), new Predicate<MachineType>() { @Override public boolean apply(MachineType input) { return input.deprecated() == null && contains(zones, input.zone()); } }); }