List of usage examples for com.google.common.collect Iterables all
public static <T> boolean all(Iterable<T> iterable, Predicate<? super T> predicate)
From source file:com.eucalyptus.vm.VmInstance.java
/** * *//*from www . ja v a 2 s . co m*/ public boolean eachVolumeAttachment(final Predicate<VmVolumeAttachment> predicate) { if (VmStateSet.DONE.contains(this.getState()) && !VmStateSet.EXPECTING_TEARDOWN.contains(this.getLastState())) { return false; } else { final EntityTransaction db = Entities.get(VmInstance.class); try { final VmInstance entity = Entities.merge(this); Set<VmVolumeAttachment> persistentAttachments = Sets .newHashSet(entity.getBootRecord().getPersistentVolumes()); boolean ret = Iterables.all(persistentAttachments, new Predicate<VmVolumeAttachment>() { @Override public boolean apply(final VmVolumeAttachment arg0) { return predicate.apply(arg0); } }); ret |= entity.getTransientVolumeState().eachVolumeAttachment(new Predicate<VmVolumeAttachment>() { @Override public boolean apply(final VmVolumeAttachment arg0) { return predicate.apply(arg0); } }); db.commit(); return ret; } catch (final Exception ex) { Logs.extreme().error(ex, ex); db.rollback(); return false; } } }