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

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

Introduction

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

Prototype

public static boolean isEmpty(Iterable<?> iterable) 

Source Link

Document

Determines if the given iterable contains no elements.

Usage

From source file:org.eclipse.sirius.ui.tools.internal.views.common.navigator.OpenRepresentationListener.java

/**
 * {@inheritDoc}//from w ww .j  a  v  a2 s  .  c o  m
 * @see org.eclipse.jface.viewers.IDoubleClickListener#doubleClick(org.eclipse.jface.viewers.DoubleClickEvent)
 */
public void doubleClick(final DoubleClickEvent event) {
    if (event != null && event.getSelection() instanceof IStructuredSelection) {
        List<?> selection = ((IStructuredSelection) event.getSelection()).toList();
        Iterable<DRepresentation> representationToOpen = getRepresentationsToOpen(selection);
        if (!Iterables.isEmpty(representationToOpen)) {
            new OpenRepresentationsAction(Sets.newLinkedHashSet(representationToOpen)).run();
        }
    }
}

From source file:com.groupon.jenkins.dynamic.build.GithubChangeLogSet.java

@Override
public boolean isEmptySet() {
    return logEntries == null || Iterables.isEmpty(logEntries);
}

From source file:com.spectralogic.ds3cli.views.cli.DetailedObjectsView.java

@Override
public String render(final GetDetailedObjectsResult obj) {
    final Iterable<DetailedS3Object> detailedS3Objects = obj.getResult();
    if (detailedS3Objects == null || Iterables.isEmpty(detailedS3Objects)) {
        return "No objects returned";
    }/*from  www  . j  a  v a 2s . c o m*/

    objects = ImmutableList.copyOf(detailedS3Objects);
    initTable(ImmutableList.of("Name", "Bucket", "Owner", "Size", "Type", "Creation Date", "Tapes", "Pools"));

    return renderTable();
}

From source file:com.palantir.atlasdb.keyvalue.api.ColumnSelection.java

public static ColumnSelection create(Iterable<byte[]> selectedColumns) {
    if (Iterables.isEmpty(Preconditions.checkNotNull(selectedColumns))) {
        return allColumnsSelected;
    }//w  w  w. j a  v  a2s  .c  om

    // Copy contents of 'selectedColumns' into a new set with proper deep comparison semantics.
    return new ColumnSelection(
            ImmutableSortedSet.copyOf(UnsignedBytes.lexicographicalComparator(), selectedColumns));
}

From source file:org.apache.brooklyn.util.exceptions.CompoundRuntimeException.java

public CompoundRuntimeException(String message, Iterable<? extends Throwable> causes) {
    this(message, (Iterables.isEmpty(causes) ? null : Iterables.get(causes, 0)), causes);
}

From source file:org.tensorics.core.iterable.lang.QuantityIterableSupport.java

public final QuantifiedValue<V> averageOf(Iterable<QuantifiedValue<V>> values) {
    if (Iterables.isEmpty(values)) {
        throw new IllegalArgumentException("Averaging of empty value set is not possible.");
    }//from w w  w. jav  a2 s  . c o  m
    return calculate(sumOf(values)).dividedBy(sizeOf(values));
}

From source file:com.synflow.ngDesign.ui.internal.navigator.CxLabelDecorator.java

@Override
public void decorate(Object element, IDecoration decoration) {
    if (element instanceof IFile) {
        IFile file = (IFile) element;/*from   w  w  w.  jav  a 2s. c  o m*/
        if (FILE_EXT_CX.equals(file.getFileExtension())) {
            Module module = getEObject(file, Module.class);
            if (module != null) {
                Iterable<Network> networks = Iterables.filter(module.getEntities(), Network.class);
                if (!Iterables.isEmpty(networks)) {
                    ImageDescriptor descriptor = CxActivator.imageDescriptorFromPlugin("com.synflow.cx.ui",
                            "icons/overlay_network.png");
                    decoration.addOverlay(descriptor);
                }
            }
        }
    }
}

From source file:org.polarsys.reqcycle.utils.iterators.collectors.WidthHarvester.java

/**
 * Width wise collection.//from w  w w.  ja v a2  s.c  o m
 * 
 * @param handler
 *            the handler that processes each element.
 * @param element
 *            : the element from which the collection is performed.
 * @throws CollectionAbortedException
 */
protected void collectWidthWise(ResultHandler<Object> handler, Object element)
        throws CollectionAbortedException {
    Iterable<?> currentLayer = Collections.singletonList(element);
    Iterable<?> nextLayer = Collections.EMPTY_LIST;
    while (currentLayer != null && !Iterables.isEmpty(currentLayer)) {
        for (Object currentElement : currentLayer) {
            try {
                handler.handleResult(currentElement);
                // Building the next layer.
                for (IPicker picker : this.getPickers()) {
                    Iterable<?> nexts = picker.getNexts(currentElement); // getting children.
                    if (nexts != null) {
                        nextLayer = Iterables.concat(nextLayer, nexts);
                    }
                }
            } catch (CannotHandleException e) {
                // do nothing
            } catch (Exception e) {
                Activator.logError(e);
            }
        }
        // The current layer has been processed. Going through the next one.
        currentLayer = nextLayer;
        nextLayer = Collections.EMPTY_LIST;
    }
}

From source file:com.spectralogic.ds3cli.views.cli.DetailedObjectsPhysicalView.java

@Override
public String render(final GetDetailedObjectsResult obj) {
    final Iterable<DetailedS3Object> detailedS3Objects = obj.getResult();
    if (detailedS3Objects == null || Iterables.isEmpty(detailedS3Objects)) {
        return "No objects returned";
    }/*from w ww .jav a2 s  .co  m*/

    objects = detailedS3Objects;
    initTable(ImmutableList.of("Name", "Bucket", "Owner", "Size", "Type", "Creation Date", "Barcode", "State"));

    return renderTable();
}

From source file:com.google.gerrit.server.query.change.FuzzyTopicPredicate.java

@Override
public boolean match(final ChangeData cd) throws OrmException {
    Change change = cd.change();/*ww  w .j  av a 2 s .  c  o  m*/
    if (change == null) {
        return false;
    }
    String t = change.getTopic();
    if (t == null) {
        return false;
    }
    try {
        Predicate<ChangeData> thisId = new LegacyChangeIdPredicate(cd.getId());
        Iterable<ChangeData> results = index.getSource(and(thisId, this), IndexedChangeQuery.oneResult())
                .read();
        return !Iterables.isEmpty(results);
    } catch (QueryParseException e) {
        throw new OrmException(e);
    }
}