public WorkUnitStream build() { return new BasicWorkUnitStream(this.workUnits, this.workUnitList, this.finiteStream, this.safeToMaterialize); } }
private void materialize() { if (this.materializedWorkUnits != null) { return; } if (!isSafeToMaterialize()) { throw new UnsupportedOperationException("WorkUnitStream is not safe to materialize."); } this.materializedWorkUnits = Lists.newArrayList(this.workUnits); }
/** * Get a materialized collection of the {@link WorkUnit}s in this stream. Note this call will fail if * {@link #isSafeToMaterialize()} is false. */ public Collection<WorkUnit> getMaterializedWorkUnitCollection() { materialize(); return this.materializedWorkUnits; }
/** * Apply a transformation function to this stream. */ public WorkUnitStream transform(Function<WorkUnit, WorkUnit> function) { if (this.materializedWorkUnits == null) { return new BasicWorkUnitStream(this, Iterators.transform(this.workUnits, function), null); } else { return new BasicWorkUnitStream(this, null, Lists.newArrayList(Lists.transform(this.materializedWorkUnits, function))); } }
/** * Get a materialized collection of the {@link WorkUnit}s in this stream. Note this call will fail if * {@link #isSafeToMaterialize()} is false. */ public Collection<WorkUnit> getMaterializedWorkUnitCollection() { materialize(); return this.materializedWorkUnits; }
private void materialize() { if (this.materializedWorkUnits != null) { return; } if (!isSafeToMaterialize()) { throw new UnsupportedOperationException("WorkUnitStream is not safe to materialize."); } this.materializedWorkUnits = Lists.newArrayList(this.workUnits); }
/** * Apply a filtering function to this stream. */ public WorkUnitStream filter(Predicate<WorkUnit> predicate) { if (this.materializedWorkUnits == null) { return new BasicWorkUnitStream(this, Iterators.filter(this.workUnits, predicate), null); } else { return new BasicWorkUnitStream(this, null, Lists.newArrayList(Iterables.filter(this.materializedWorkUnits, predicate))); } }
public WorkUnitStream build() { return new BasicWorkUnitStream(this.workUnits, this.workUnitList, this.finiteStream, this.safeToMaterialize); } }
/** * Apply a transformation function to this stream. */ public WorkUnitStream transform(Function<WorkUnit, WorkUnit> function) { if (this.materializedWorkUnits == null) { return new BasicWorkUnitStream(this, Iterators.transform(this.workUnits, function), null); } else { return new BasicWorkUnitStream(this, null, Lists.newArrayList(Lists.transform(this.materializedWorkUnits, function))); } }
/** * Apply a filtering function to this stream. */ public WorkUnitStream filter(Predicate<WorkUnit> predicate) { if (this.materializedWorkUnits == null) { return new BasicWorkUnitStream(this, Iterators.filter(this.workUnits, predicate), null); } else { return new BasicWorkUnitStream(this, null, Lists.newArrayList(Iterables.filter(this.materializedWorkUnits, predicate))); } }