List of usage examples for com.google.common.collect Iterables size
public static int size(Iterable<?> iterable)
From source file:org.sitemap4j.sitemapindex.AbstractSiteMapIndex.java
@Override public boolean equals(final Object object) { if (object == this) { return true; } else if (object == null) { return false; } else if (!(object instanceof SiteMapIndex)) { return false; }/*from www . ja v a 2 s .co m*/ final SiteMapIndex that = (SiteMapIndex) 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.eclipse.elk.tree.TreeUtil.java
/** * This method returns the leftmost node at the given level. This is implemented using a * postorder walk of the subtree under given level, depth levels down. Depth here refers to the * level below where the leftmost descendant is being found. * //from w w w.j a v a 2s . c om * If given level is negative it returns the leftmost node at the deepest level. * * @param currentlevel * a list of nodes at level one * @param depth * the depth to search for * @return the leftmost descendant at depth levels down */ public static TNode getLeftMost(final Iterable<TNode> currentlevel, final int depth) { if (0 < Iterables.size(currentlevel)) { int d = depth; // the leftmost descendant at depth levels down if (1 < d) { d--; // build empty iterator Iterable<TNode> nextLevel = new Iterable<TNode>() { public Iterator<TNode> iterator() { return Iterators.emptyIterator(); } }; for (TNode cN : currentlevel) { // append the children of the current node to the next level nextLevel = Iterables.concat(nextLevel, cN.getChildren()); } return getLeftMost(nextLevel, d); } // the leftmost node at the deepest level if (d < 0) { // build empty iterator Iterable<TNode> nextLevel = new Iterable<TNode>() { public Iterator<TNode> iterator() { return Iterators.emptyIterator(); } }; for (TNode cN : currentlevel) { // append the children of the current node to the next level nextLevel = Iterables.concat(nextLevel, cN.getChildren()); } // if (0 < Iterables.size(nextLevel)) { return getLeftMost(nextLevel, d); } } } // return the leftmost node at the current level return Iterables.getFirst(currentlevel, null); }
From source file:org.jclouds.functions.OnlyElementOrNull.java
@Override public T apply(Iterable<T> arg0) { if (arg0 == null || Iterables.size(arg0) == 0) return null; return Iterables.getOnlyElement(arg0); }
From source file:com.google.security.zynamics.binnavi.disassembly.views.CViewFilter.java
/** * Returns the number of views of type CALLGRAPH. * /*from ww w . ja va 2 s . c o m*/ * @param views The list of views. * @return The number of views of type CALLGRAPH: */ public static int getCallgraphViewCount(final List<INaviView> views) { return Iterables.size(getViewsByType(views, GraphType.CALLGRAPH)); }
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:org.apache.metron.dataloads.nonbulk.taxii.TableInfo.java
public TableInfo(String s) { Iterable<String> i = Splitter.on(":").split(s); if (Iterables.size(i) != 2) { throw new IllegalStateException("Malformed table:cf => " + s); }//from w ww . ja va 2 s.c om tableName = Iterables.getFirst(i, null); columnFamily = Iterables.getLast(i); }
From source file:com.facebook.buck.core.model.actiongraph.ActionGraph.java
public int getSize() { return Iterables.size(nodes); }
From source file:com.freiheit.fuava.simplebatch.fetch.PageFetchingSettings.java
default boolean hasNext(final int from, final int amount, final Result<PagingInput, T> lastValue) { if (lastValue == null || !lastValue.isSuccess()) { return false; }/*from w w w .j a va 2s.c om*/ final Object output = lastValue.getOutput(); if (output instanceof Iterable) { return Iterables.size((Iterable) output) >= amount; } throw new UnsupportedOperationException( "cannot calculate paging for " + output + " - please provide your own implementation"); }
From source file:org.janusgraph.util.datastructures.IterablesUtil.java
public static final int size(Iterable i) { if (i instanceof Collection) return ((Collection) i).size(); else//from www . j a v a 2 s . c om return Iterables.size(i); }
From source file:org.apache.fluo.command.FluoWait.java
private static long countNotifications(Environment env) { Scanner scanner;/* www.j ava 2 s. c o m*/ try { scanner = env.getConnector().createScanner(env.getTable(), env.getAuthorizations()); } catch (TableNotFoundException e) { log.error("An exception was thrown -", e); throw new FluoException(e); } Notification.configureScanner(scanner); return Iterables.size(scanner); }