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.spongepowered.common.data.processor.common.GoldenAppleUtils.java
public static GoldenApple getType(ItemStack itemStack) { return Iterables.get(SpongeImpl.getRegistry().getAllOf(GoldenApple.class), itemStack.getMetadata()); }
From source file:com.cinchapi.common.collect.Collectives.java
/** * Intelligently merged collectives {@code a} and {@code b}. * /*from w ww.j a v a 2 s . co m*/ * @param a * @param b * @return the merged collection */ public static Collection<Object> merge(Collection<Object> a, Collection<Object> b) { int i = 0; int asize = a.size(); int bsize = b.size(); Collection<Object> merged = Lists.newArrayListWithCapacity(Math.max(asize, bsize)); for (; i < Math.min(asize, bsize); ++i) { Object ai = Iterables.get(a, i); Object bi = Iterables.get(b, i); Object merger = merge(ai, bi); if (merger != null) { merged.add(merger); } else { if (ai != null) { merged.add(ai); } if (bi != null) { merged.add(bi); } } } for (; i < a.size(); ++i) { merged.add(Iterables.get(a, i)); } for (; i < b.size(); ++i) { merged.add(Iterables.get(b, i)); } return merged; }
From source file:co.cask.cdap.logging.gateway.handlers.FormattedLogEvent.java
public static LogOffset parseLogOffset(String offsetStr) { if (offsetStr.isEmpty()) { return LogOffset.LATEST_OFFSET; }/*from w w w . j a va2 s .co m*/ Iterable<String> splits = Splitter.on(SEPARATOR).split(offsetStr); Preconditions.checkArgument(Iterables.size(splits) == 2, "Invalid offset provided: %s", offsetStr); return new LogOffset(Long.valueOf(Iterables.get(splits, 0)), Long.valueOf(Iterables.get(splits, 1))); }
From source file:org.jbb.frontend.web.acp.controller.AcpController.java
@RequestMapping("/acp") public String acpMain() { List<AcpCategory> acpCategories = acpService.selectAllCategoriesOrdered(); return "redirect:/acp/" + Iterables.get(acpCategories, 0).getViewName(); }
From source file:org.jclouds.vcloud.domain.network.internal.VCloudExpressOrgNetworkAdapter.java
static Configuration parseConfiguration(VCloudExpressNetwork in) { String dns1 = (in.getDnsServers().size() > 0) ? Iterables.get(in.getDnsServers(), 0) : null; String dns2 = (in.getDnsServers().size() > 1) ? Iterables.get(in.getDnsServers(), 1) : null; String gateway = in.getGateway(); String netmask = in.getNetmask(); FenceMode mode = in.getFenceModes().size() > 0 ? Iterables.get(in.getFenceModes(), 0) : FenceMode.BRIDGED; DhcpService dhcp = in.isDhcp() != null && in.isDhcp() ? new DhcpService(true, null, null, null) : null; NatService nat = in.getNatRules().size() > 0 ? new NatService(true, null, null, in.getNatRules()) : null; FirewallService firewall = in.getFirewallRules().size() > 0 ? new FirewallService(true, in.getFirewallRules()) : null;// w w w . j a va2 s . c o m return new OrgNetworkImpl.ConfigurationImpl(new IpScope(true, gateway, netmask, dns1, dns2, null, ImmutableSet.<IpRange>of(), ImmutableSet.<String>of()), null, mode, new Features(dhcp, firewall, nat)); }
From source file:org.jbb.frontend.web.ucp.controller.UcpController.java
@RequestMapping("/ucp") public String ucpMain() { List<UcpCategory> ucpCategories = ucpService.selectAllCategoriesOrdered(); return "redirect:/ucp/" + Iterables.get(ucpCategories, 0).getViewName(); }
From source file:com.eightkdata.mongowp.bson.abst.AbstractIterableBasedBsonArray.java
@Override public BsonValue<?> get(int index) { return Iterables.get(this, index); }
From source file:com.reprezen.swagedit.model.ObjectNode.java
@Override public AbstractNode get(int pos) { return Iterables.get(elements.values(), pos); }
From source file:org.zalando.github.spring.pagination.StringToLinkRelation.java
@Override public LinkRelation apply(String input) { Iterable<String> splittResult = splitter.split(input); String link = Iterables.get(splittResult, 0); link = StringUtils.trimAllWhitespace(link); link = StringUtils.trimLeadingCharacter(link, '<'); link = StringUtils.trimTrailingCharacter(link, '>'); String relation = Iterables.get(splittResult, 1); relation = StringUtils.trimAllWhitespace(relation); return new LinkRelation(link, relation); }
From source file:qa.qcri.nadeef.test.udf.IncPairRule1.java
@Override public Collection<Table> block(Collection<Table> tables) { Table table = Iterables.get(tables, 0); return table.groupOn("C"); }