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(int idClient) { Query query = em.createNamedQuery("Devisgeneral.findByIdclient"); query.setParameter("idclient", idClient); 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 CIMOperatingSystem toComputeOs(VApp vApp) { // TODO we need to change the design so that it doesn't assume single-vms return vApp.getChildren().size() > 0 ? toComputeOs(Iterables.get(vApp.getChildren(), 0)) : null; }
From source file:org.jclouds.openstack.nova.v1_1.domain.zonescoped.ZoneAndName.java
public static ZoneAndName fromSlashEncoded(String name) { Iterable<String> parts = Splitter.on('/').split(checkNotNull(name, "name")); checkArgument(Iterables.size(parts) == 2, "name must be in format zoneId/name"); return new ZoneAndName(Iterables.get(parts, 0), Iterables.get(parts, 1)); }
From source file:sklearn.ensemble.gradient_boosting.LogOddsEstimator.java
@Override public Number getPriorProbability(int index) { return Iterables.get(getPrior(), index); }
From source file:sklearn.ensemble.gradient_boosting.PriorProbabilityEstimator.java
@Override public Number getPriorProbability(int index) { return Iterables.get(getPriors(), index); }
From source file:com.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.// w w w . j a v a 2s . 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) { // TODO call into second method with getMicros() int start = 0; int end = timestamps.size() - 1; while (start <= end) { int mid = (start + end) / 2; Timestamp stored = Iterables.get(timestamps, mid); if (sought.getMicros() == stored.getMicros()) { return mid; } else if (sought.getMicros() > stored.getMicros()) { start = mid + 1; } else { end = mid - 1; } } return start; }
From source file:de.lgblaumeiser.ptm.analysis.analyzer.HourComputer.java
@Override public Collection<Collection<Object>> analyze(final Collection<String> parameter) { YearMonth requestedMonth = YearMonth.now(); if (parameter.size() > 0) { requestedMonth = YearMonth.parse(Iterables.get(parameter, 0)); }// w w w . ja v a 2 s .c om Collection<Collection<Object>> result = Lists.newArrayList(); result.add(Arrays.asList("Work Day", "Starttime", "Endtime", "Presence", "Worktime", "Breaktime", "Overtime", "Comment")); Duration overtime = Duration.ZERO; LocalDate currentday = requestedMonth.atDay(1); while (!currentday.isAfter(requestedMonth.atEndOfMonth())) { Collection<Booking> currentBookings = getBookingsForDay(currentday); if (hasCompleteBookings(currentBookings)) { String day = currentday.format(DateTimeFormatter.ISO_LOCAL_DATE); LocalTime starttime = Iterables.getFirst(currentBookings, null).getStarttime(); LocalTime endtime = Iterables.getLast(currentBookings).getEndtime(); Duration presence = calculatePresence(starttime, endtime); Duration worktime = calculateWorktime(currentBookings); Duration breaktime = calculateBreaktime(presence, worktime); Duration currentOvertime = calculateOvertime(worktime, currentday); overtime = overtime.plus(currentOvertime); result.add(Arrays.asList(day, starttime.format(DateTimeFormatter.ofPattern("HH:mm")), endtime.format(DateTimeFormatter.ofPattern("HH:mm")), formatDuration(presence), formatDuration(worktime), formatDuration(breaktime), formatDuration(overtime), validate(worktime, breaktime))); } currentday = currentday.plusDays(1); } return result; }
From source file:org.sitemap4j.sitemap.AbstractSiteMap.java
@Override public boolean equals(final Object object) { if (object == this) { return true; } else if (object == null) { return false; } else if (!(object instanceof SiteMap)) { return false; }// w w w.j a v a2 s.com final SiteMap that = (SiteMap) object; if (Iterables.size(that) != Iterables.size(this)) { return false; } for (int i = 0; i < Iterables.size(this); i++) { if (!Iterables.get(this, i).equals(Iterables.get(that, i))) { return false; } } return true; }
From source file:org.jclouds.joyent.cloudapi.v6_5.domain.datacenterscoped.DatacenterAndName.java
public static DatacenterAndName fromSlashEncoded(String name) { Iterable<String> parts = Splitter.on('/').split(checkNotNull(name, "name")); checkArgument(Iterables.size(parts) == 2, "name must be in format datacenterId/name"); return new DatacenterAndName(Iterables.get(parts, 0), Iterables.get(parts, 1)); }
From source file:qa.qcri.nadeef.test.udf.AdultRule2.java
@Override public Collection<Table> block(Collection<Table> tables) { Table table = Iterables.get(tables, 0); return table.groupOn("race"); }