List of usage examples for com.google.common.collect Iterables get
public static <T> T get(Iterable<T> iterable, int position)
From source file:org.jclouds.vcloud.compute.util.VCloudComputeUtils.java
public static LoginCredentials getCredentialsFrom(VAppTemplate vApp) { return vApp.getChildren().size() > 0 ? getCredentialsFrom(Iterables.get(vApp.getChildren(), 0)) : null; }
From source file:edu.mit.streamjit.impl.interp.BlockingQueueChannel.java
@Override public E peek(int index) { return Iterables.get(queue, index); }
From source file:com.torodb.kvdocument.values.KvArray.java
@Nonnull public KvValue<?> get(int index) throws IndexOutOfBoundsException { return Iterables.get(this, index); }
From source file:me.emily.irc.protocol.parser.UserModeParser.java
@Override public boolean recieve(String message, ServerConnection connection) { Matcher matcher = pattern.matcher(message); if (matcher.matches()) { Channel channel = connection.getChannel(matcher.group(2)); User user = User.parse(matcher.group(1), connection); String params = matcher.group(4); params = params == null ? "" : params; Iterable<String> parameters = splitter.split(params); int p = 0; boolean add; for (char c : matcher.group(3).toCharArray()) { switch (c) { case '+': add = true;/*from w w w . j a v a2s.co m*/ break; case '-': add = false; break; default: if (takesParams(c, connection)) { String param = Iterables.get(parameters, p); p++; } else { } } } return true; } return false; }
From source file:edu.tsinghua.software.pages.template.TwitterBootstrapNavBarPanel.java
private TwitterBootstrapNavBarPanel(final Builder builder) { super(builder.id); BookmarkablePageLink<Void> homePageLink = new BookmarkablePageLink<Void>("homePageLink", builder.homePage); homePageLink.add(new Label("label", builder.applicationName)); add(homePageLink);//ww w . j a v a 2 s .c o m RepeatingView repeatingView = new RepeatingView("menuItems"); for (MenuItemEnum item : builder.linksMap.keySet()) { boolean shouldBeActive = item.equals(builder.activeMenuItem); Collection<BookmarkablePageLink<?>> linksInThisMenuItem = builder.linksMap.get(item); if (linksInThisMenuItem.size() == 1) { BookmarkablePageLink<?> pageLink = Iterables.get(linksInThisMenuItem, 0); MenuLinkItem menuLinkItem = new MenuLinkItem(repeatingView.newChildId(), pageLink, shouldBeActive); repeatingView.add(menuLinkItem); } else { repeatingView.add(new MenuDropdownItem(repeatingView.newChildId(), item, linksInThisMenuItem, shouldBeActive)); } } add(repeatingView); }
From source file:org.jclouds.aws.s3.blobstore.functions.BucketToResourceMetadata.java
@Inject BucketToResourceMetadata(S3Client client, @Memoized Supplier<Set<? extends Location>> locations) { this.client = client; this.onlyLocation = locations.get().size() == 1 ? Iterables.get(locations.get(), 0) : null; this.locations = locations; }
From source file:com.cinchapi.common.collect.Collections.java
/** * Return a {@link List} that is a read-only view to the {@code collection}. * /*w ww.j a v a2 s . c o m*/ * @param collection * @return the {@link List} view */ public static <T> List<T> viewOf(Collection<T> collection) { return new AbstractList<T>() { @Override public T get(int index) { return Iterables.get(collection, index); } @Override public int size() { return collection.size(); } }; }
From source file:org.jclouds.trmk.vcloud_0_8.functions.OrgNameAndCatalogNameToEndpoint.java
@SuppressWarnings("unchecked") public URI apply(Object from) { Iterable<Object> orgCatalog = (Iterable<Object>) checkNotNull(from, "args"); Object org = Iterables.get(orgCatalog, 0); Object catalog = Iterables.get(orgCatalog, 1); if (org == null && catalog == null) return defaultCatalog.get().getHref(); else if (org == null) org = defaultOrg.get().getName(); try {//from w ww .j a va 2s .co m Map<String, ReferenceType> catalogs = checkNotNull(orgMap.get().get(org)).getCatalogs(); return catalog == null ? Iterables.getLast(catalogs.values()).getHref() : catalogs.get(catalog).getHref(); } catch (NullPointerException e) { throw new NoSuchElementException(org + "/" + catalog + " not found in " + orgMap.get()); } }
From source file:org.jclouds.rackspace.cloudloadbalancers.functions.UnwrapLoadBalancers.java
@Override public Set<LoadBalancer> apply(HttpResponse arg0) { Map<String, Set<LB>> map = json.apply(arg0); if (map.size() == 0) return ImmutableSet.<LoadBalancer>of(); return ImmutableSet.copyOf(Iterables.transform(Iterables.get(map.values(), 0), convertLB)); }
From source file:org.jclouds.rackspace.cloudloadbalancers.functions.ParseLoadBalancer.java
@Override public LoadBalancer apply(HttpResponse arg0) { checkState(convertLB != null, "convertLB should be set by InvocationContext"); Map<String, LB> map = json.apply(arg0); if (map == null || map.size() == 0) return null; LB lb = Iterables.get(map.values(), 0); return convertLB.apply(lb); }