List of usage examples for com.google.common.collect Iterables get
public static <T> T get(Iterable<T> iterable, int position)
From source file:gokalp.icus.ejb.DevisGeneralEJB.java
public Collection<Devisgeneral> getDevis(String nomClient) { Query query = em.createNamedQuery("Devisgeneral.findBySociete"); query.setParameter("societe", nomClient); Collection<Devisgeneral> devis = query.getResultList(); Iterables.get(devis, 0).getDevisdetailsCollection().size(); return devis; }
From source file:org.jclouds.vcloud.compute.util.VCloudComputeUtils.java
public static String getVirtualSystemIdentifierOfFirstVMIn(VApp vApp) { return vApp.getChildren().size() > 0 ? getVirtualSystemIdentifierOf(Iterables.get(vApp.getChildren(), 0)) : null;//from w w w .ja v a2 s . co m }
From source file:org.nuxeo.ecm.core.query.sql.model.FromList.java
/** * Don't use this method anymore. Now we can easily iterate over {@link FromList} with {@link #keySet()}, * {@link #values()} or {@link #entrySet()}. * <p />/*from w w w. j a v a 2s. c o m*/ * We kept this method because removing it could lead to regressions as ({@link #get(Object)} is a candidate. * * @deprecated since 9.1 */ @Deprecated public String get(int i) { return Iterables.get(values(), i); }
From source file:org.onosproject.segmentrouting.grouphandler.RandomNeighborSet.java
@Override public DeviceId getFirstNeighbor() { if (getDeviceIds().isEmpty()) { return DeviceId.NONE; }/*from w w w.j av a 2s . co m*/ int size = getDeviceIds().size(); int index = RandomUtils.nextInt(0, size); return Iterables.get(getDeviceIds(), index); }
From source file:org.cinchapi.concourse.util.Timestamps.java
/** * Search the chronological set of {@code timestamps} to return the index of * a contained timestamp that occurs after the {@code sought} timestamp * and more closely than any others.//from ww w . j a v a2 s .c o m * <p> * <ul> * <li>If the search set is empty, this function will return {@code 0}</li> * <li>If the sought timestamp is smaller than every timestamp in the search * set, this function will return {@code 0}</li> * <li>If the sought timestamp is greater than every timestamp in the search * set, this function will return the size of the search set, which is 1 * greater than the last index in the search set</li> * </ul> * </p> * * @param timestamps * @param sought * @return an index of nearest successor timestamp */ public static int findNearestSuccessorForTimestamp(Set<Timestamp> timestamps, Timestamp sought) { int start = 0; int end = timestamps.size() - 1; while (start <= end) { int mid = (start + end) / 2; Timestamp stored = Iterables.get(timestamps, mid); if (stored.getMicros() == sought.getMicros()) { return mid + 1; } else if (stored.getMicros() < sought.getMicros()) { start = mid + 1; } else { end = mid - 1; } } return start; }
From source file:org.nuxeo.ecm.core.query.sql.model.SelectList.java
/** * Don't use this method anymore. Now we can easily iterate over {@link SelectList} with {@link #keySet()}, * {@link #values()} or {@link #entrySet()}. * <p />/*ww w .java2s . co m*/ * We kept this method because removing it could lead to regressions as ({@link #get(Object)} is a candidate. * * @deprecated since 9.1 */ @Deprecated public Operand get(int i) { return Iterables.get(values(), i); }
From source file:org.jclouds.softlayer.compute.functions.ProductItems.java
/** * Creates a function to get the ProductItemPrice for the ProductItem. Currently returns the * first prices. This will need to be changed if more than one prices is returned. *///from ww w . ja va2s . c o m public static Function<ProductItem, ProductItemPrice> price() { return new Function<ProductItem, ProductItemPrice>() { @Override public ProductItemPrice apply(ProductItem productItem) { if (productItem.getPrices().size() < 1) throw new NoSuchElementException("ProductItem has no prices:" + productItem); return Iterables.get(productItem.getPrices(), 0); } }; }
From source file:com.facebook.presto.block.BlockUtils.java
public static BlockIterable toBlocks(DataSize dataSize, int positionCount, Iterable<Block> blocks) { return new BlocksIterableAdapter(Iterables.get(blocks, 0).getTupleInfo(), Optional.of(dataSize), Optional.of(positionCount), blocks); }
From source file:com.cinchapi.concourse.lang.ast.ConjunctionTree.java
/** * Return the left child of this {@link ConjunctionTree}. * * @return the left child */ public AST getLeftChild() { return Iterables.get(children(), 0); }
From source file:com.googlecode.blaisemath.util.xml.PointAdapter.java
@Override public Point unmarshal(String v) { if (v == null) { return null; }/*from w w w .j a va 2 s .c o m*/ Matcher m = Pattern.compile("point\\[(.*)\\]").matcher(v.toLowerCase().trim()); if (m.find()) { String inner = m.group(1); Iterable<String> kv = Splitter.on(",").trimResults().split(inner); try { int x = Integer.valueOf(Iterables.get(kv, 0)); int y = Integer.valueOf(Iterables.get(kv, 1)); return new Point(x, y); } catch (NumberFormatException x) { Logger.getLogger(PointAdapter.class.getName()).log(Level.FINEST, "Not an integer", x); return null; } } else { Logger.getLogger(PointAdapter.class.getName()).log(Level.FINEST, "Not a valid point", v); return null; } }