Example usage for com.google.common.collect Iterables size

List of usage examples for com.google.common.collect Iterables size

Introduction

In this page you can find the example usage for com.google.common.collect Iterables size.

Prototype

public static int size(Iterable<?> iterable) 

Source Link

Document

Returns the number of elements in iterable .

Usage

From source file:eu.esdihumboldt.hale.ui.schema.presets.internal.SchemaPresetContentProvider.java

@Override
public Object[] getElements(Object inputElement) {
    if (forceCategories) {
        return ArrayContentProvider.getInstance().getElements(inputElement);
    } else {/*w w w  . j a v  a 2s .co  m*/
        // only show categories for categories with more than one child
        List<Object> result = new ArrayList<>();
        for (Object element : ArrayContentProvider.getInstance().getElements(inputElement)) {
            if (element instanceof SchemaCategory) {
                SchemaCategory cat = (SchemaCategory) element;
                if (SchemaCategoryExtension.DEFAULT_CATEGORY.equals(cat)) {
                    // add all schemas w/o category
                    Iterables.addAll(result, cat.getSchemas());
                } else {
                    int numSchemas = Iterables.size(cat.getSchemas());
                    if (numSchemas > 1) {
                        // add category
                        result.add(cat);
                    } else if (numSchemas == 1) {
                        // add schemas
                        result.add(cat.getSchemas().iterator().next());
                    }
                }
            } else
                result.add(element);
        }
        return result.toArray();
    }
}

From source file:org.eclipse.sirius.tests.swtbot.sequence.condition.CheckNumberOfChildren.java

public boolean test() throws Exception {
    List<SWTBotGefEditPart> children = gefBot.children();
    final Matcher<? extends GraphicalEditPart> instanceOf = IsInstanceOf.instanceOf(editPartClass);
    Predicate<SWTBotGefEditPart> requested = new Predicate<SWTBotGefEditPart>() {
        /**/*from  w w  w. ja  v a  2  s  .c  o m*/
         * {@inheritDoc}
         */
        public boolean apply(SWTBotGefEditPart input) {
            return instanceOf.matches(input);
        }
    };

    return Iterables.size(Iterables.filter(children, requested)) == expectedEditPartNumber;

}

From source file:org.eclipse.xtext.resource.impl.DefaultResourceDescriptionDelta.java

protected boolean internalHasChanges() {
    if (_new == null || old == null)
        return true;

    Iterable<IEObjectDescription> oldEObjects = old.getExportedObjects();
    Iterable<IEObjectDescription> newEObjects = _new.getExportedObjects();
    if (Iterables.size(oldEObjects) != Iterables.size(newEObjects))
        return true;

    Iterator<IEObjectDescription> iterator1 = oldEObjects.iterator();
    Iterator<IEObjectDescription> iterator2 = newEObjects.iterator();
    while (iterator1.hasNext()) {
        if (!equals(iterator1.next(), iterator2.next()))
            return true;
    }//  ww w. ja  v a2 s  .c o  m
    return false;
}

From source file:com.yammer.collections.azure.CellSetMutableView.java

@Override
public int size() {
    return Iterables.size(getBackingIterable());
}

From source file:org.icgc.dcc.release.job.summarize.function.SummarizeDonorGene.java

@Override
public Tuple2<String, ObjectNode> call(Tuple2<ObjectNode, Iterable<ObjectNode>> tuple) throws Exception {
    val fields = tuple._1;
    val group = tuple._2;

    val donorId = fields.get("_donor_id").asText();
    val geneId = fields.get("_gene_id").asText();
    val summary = fields.objectNode();
    summary.put("_ssm_count", Iterables.size(group));

    val geneSummary = fields.objectNode();
    geneSummary.put("_gene_id", geneId);
    geneSummary.set("_summary", summary);

    return new Tuple2<String, ObjectNode>(donorId, geneSummary);
}

From source file:com.google.security.zynamics.binnavi.disassembly.views.CViewFilter.java

/**
 * Returns the number of views of type MIXED_GRAPH.
 * //from ww w  . j  ava  2s  . co  m
 * @param views The list of views.
 * @return The number of views of type MIXED_GRAPH:
 */
public static int getMixedgraphViewCount(final List<INaviView> views) {
    return Iterables.size(getViewsByType(views, GraphType.MIXED_GRAPH));
}

From source file:org.obm.push.mail.mime.MimeAddress.java

public int countNestLevel() {
    if (nestLevel == null) {
        nestLevel = Iterables.size(Splitter.on(".").split(address));
    }//from  w ww. jav a  2 s.  c o  m
    return nestLevel;
}

From source file:org.obiba.opal.core.cfg.OpalConfiguration.java

public <T extends OpalConfigurationExtension> boolean hasExtension(Class<T> type) {
    return Iterables.size(Iterables.filter(extensions, type)) == 1;
}

From source file:brooklyn.location.docker.strategy.GroupPlacementStrategy.java

@Override
public boolean apply(DockerHostLocation input) {
    boolean requireExclusive = config().get(REQUIRE_EXCLUSIVE);
    String dockerApplicationId = input.getOwner().getApplicationId();
    Iterable<Entity> deployed = Iterables.filter(input.getDockerContainerList(),
            Predicates.not(EntityPredicates.applicationIdEqualTo(dockerApplicationId)));
    Entity parent = entity.getParent();
    String applicationId = entity.getApplicationId();
    Iterable<Entity> sameApplication = Iterables.filter(deployed,
            EntityPredicates.applicationIdEqualTo(applicationId));
    if (requireExclusive && Iterables.size(deployed) > Iterables.size(sameApplication)) {
        LOG.debug("Found entities not in {}; required exclusive. Reject: {}", applicationId, input);
        return false;
    }//  w ww .  ja  v  a2 s  .  c o  m
    if (Iterables.isEmpty(sameApplication)) {
        LOG.debug("No entities present from {}. Accept: {}", applicationId, input);
        return true;
    } else {
        Iterable<Entity> sameParent = Iterables.filter(sameApplication, EntityPredicates.isChildOf(parent));
        if (Iterables.isEmpty(sameParent)) {
            LOG.debug("All entities from {} have different parent. Reject: {}", applicationId, input);
            return false;
        } else {
            LOG.debug("All entities from {} have same parent. Accept: {}", applicationId, input);
            return true;
        }
    }
}

From source file:org.terasology.logic.console.ui.NotificationOverlay.java

@Override
public void initialise() {
    message = find("message", UILabel.class);
    message.bindText(new ReadOnlyBinding<String>() {
        @Override// w w  w. j ava2s .com
        public String get() {
            Iterable<Message> msgs = console.getMessages(CoreMessageType.CHAT, CoreMessageType.NOTIFICATION);
            StringBuilder messageHistory = new StringBuilder();
            int count = 1;
            int size = Iterables.size(msgs);

            for (Message msg : msgs) {
                if (count > size - MAX_MESSAGES) {
                    messageHistory.append(StringUtils.abbreviate(msg.getMessage(), MAX_CHAR_PER_MSG));
                    if (count < size) {
                        messageHistory.append(Console.NEW_LINE);
                    }
                }
                count++;
            }

            return messageHistory.toString();
        }
    });
}