Java Code Examples for java.util.stream.Stream#empty()
The following examples show how to use
java.util.stream.Stream#empty() .
These examples are extracted from open source projects.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: pitest File: FilterTester.java License: Apache License 2.0 | 6 votes |
private List<Sample> samples(final String sample) { final Function<String, Stream<Sample>> toPair = compiler -> { final String clazz = makeClassName(sample, compiler); final Optional<byte[]> bs = FilterTester.this.source.getBytes(clazz); if (bs.isPresent()) { final Sample p = new Sample(); p.className = ClassName.fromString(clazz); p.clazz = ClassTree.fromBytes(bs.get()); p.compiler = compiler; return Stream.of(p); } return Stream.empty(); }; return COMPILERS.stream().flatMap(toPair).collect(Collectors.toList()); }
Example 2
Source Project: grakn File: QueryExecutorImpl.java License: GNU Affero General Public License v3.0 | 6 votes |
@Override public Stream<ConceptMap> match(MatchClause matchClause) { Stream<ConceptMap> answerStream; try { validateClause(matchClause); Set<Variable> bindingVars = matchClause.getPatterns().variables(); Disjunction<Conjunction<Pattern>> disjunction = matchClause.getPatterns().getNegationDNF(); ResolvableQuery resolvableQuery = reasonerQueryFactory.resolvable(disjunction, bindingVars); return resolvableQuery.resolve(infer); } catch (ReasonerCheckedException e) { LOG.debug(e.getMessage()); answerStream = Stream.empty(); } return answerStream; }
Example 3
Source Project: openjdk-jdk9 File: Analyzer.java License: GNU General Public License v2.0 | 5 votes |
/** * Returns the direct dependences of the given source */ Stream<Archive> requires(Archive source) { if (!results.containsKey(source)) { return Stream.empty(); } return results.get(source).requires() .stream(); }
Example 4
Source Project: tutorials File: NullSafeCollectionStreamsUsingJava8OptionalContainerUnitTest.java License: MIT License | 5 votes |
@Test public void whenCollectionIsNull_thenExpectAnEmptyStream() { Collection<String> collection = null; Stream<String> expResult = Stream.empty(); Stream<String> result = instance.collectionAsStream(collection); assertStreamEquals(expResult, result); }
Example 5
Source Project: flux File: DirectoryBasedDeploymentUnitUtil.java License: Apache License 2.0 | 5 votes |
/** * Helper method to list sub-directories. * @param path * @return {@code Stream<Path>} representing sub-directories */ private Stream<Path> getSubDirectories(Path path) { try { return Files.list(path).filter(e -> Files.isDirectory(e)); } catch (IOException ioe) { return Stream.empty(); } }
Example 6
Source Project: timbuctoo File: BdbTruePatchStore.java License: GNU General Public License v3.0 | 5 votes |
public Stream<CursorQuad> getChanges(String subject, String predicate, Direction direction, int version, boolean assertions) { if (bdbWrappers.containsKey(version)) { final BdbWrapper<String, String> bdbWrapper = bdbWrappers.get(version); return bdbWrapper.databaseGetter() .key(subject + "\n" + version + "\n" + (assertions ? "1" : "0")) .skipNearValue(predicate + "\n" + (direction == OUT ? "1" : "0") + "\n") .onlyValuesMatching((prefix, value) -> value.startsWith(prefix)) .forwards() .getValues(bdbWrapper.valueRetriever()) .map(v -> makeCursorQuad(subject, assertions, v)); } return Stream.empty(); }
Example 7
Source Project: protonpack File: StateMachineRunner.java License: MIT License | 5 votes |
private Stream<O> _finish() { if (isFinished) { return Stream.empty(); } isFinished = true; return stateMachine.finish(state); }
Example 8
Source Project: reactor-core File: FluxProcessor.java License: Apache License 2.0 | 4 votes |
@Override public Stream<? extends Scannable> inners() { return Stream.empty(); }
Example 9
Source Project: metasfresh-webui-api-legacy File: ProductsProposalViewFactoryTemplate.java License: GNU General Public License v3.0 | 4 votes |
@Override public final Stream<IView> streamAllViews() { return Stream.empty(); }
Example 10
Source Project: tcases File: InputModeller.java License: MIT License | 4 votes |
/** * Returns an empty stream for a schema of unknown type. */ private Stream<IVarDef> unknownSchemaVars( String type) { notifyError( String.format( "Unknown schema type=%s is not supported", type), "Ignoring unknown schema"); return Stream.empty(); }
Example 11
Source Project: armeria File: StringMultimapBuilder.java License: Apache License 2.0 | 4 votes |
public final Stream<String> valueStream(IN_NAME name) { final CONTAINER getters = getters(); return getters != null ? getters.valueStream(name) : Stream.empty(); }
Example 12
Source Project: WarpPI File: NumberPattern.java License: Apache License 2.0 | 4 votes |
@Override public Stream<SubFunctionPattern> getSubFunctions() { return Stream.empty(); }
Example 13
Source Project: openhab-core File: RFC2217PortProvider.java License: Eclipse Public License 2.0 | 4 votes |
@Override public Stream<SerialPortIdentifier> getSerialPortIdentifiers() { // TODO implement discovery here. https://github.com/eclipse/smarthome/pull/5560 return Stream.empty(); }
Example 14
Source Project: tcases File: DateDomain.java License: MIT License | 4 votes |
/** * Returns a random sequence of time values from this domain. */ protected Stream<Date> timeValues( ResolverContext context) { Calendar minDate = new Calendar.Builder() .setInstant( getMinDate()) .build(); long minTime = new Calendar.Builder() .setDate( minDate.get( YEAR), minDate.get( MONTH), minDate.get( DAY_OF_MONTH)) .setTimeOfDay( 0, 0, 0, 0) .build() .getTimeInMillis(); Calendar maxDate = new Calendar.Builder() .setInstant( getMaxDate()) .build(); long maxTime = new Calendar.Builder() .setDate( maxDate.get( YEAR), maxDate.get( MONTH), maxDate.get( DAY_OF_MONTH)) .setTimeOfDay( 0, 0, 0, 0) .build() .getTimeInMillis(); long millisPerDay = 86400000; long daysCount = (maxTime - minTime) / millisPerDay + 1; return daysCount < 1? Stream.empty() : daysCount == 1? Stream.of( getMinDate()) : context.getRandom().longs( 0, daysCount) .map( d -> minTime + d * millisPerDay) .mapToObj( Date::new); }
Example 15
Source Project: hol-streams File: Unit2MyIntermediate.java License: Apache License 2.0 | 4 votes |
@Override public Stream<String> strings(Stream<Object> stream) { return Stream.empty(); }
Example 16
Source Project: synapse File: MessageStores.java License: Apache License 2.0 | 4 votes |
@Override public Stream<MessageStoreEntry> stream() { return Stream.empty(); }
Example 17
Source Project: reactor-core File: FluxWindowPredicate.java License: Apache License 2.0 | 4 votes |
@Override public Stream<? extends Scannable> inners() { return window == null ? Stream.empty() : Stream.of(window); }
Example 18
Source Project: freecol File: FreeColObject.java License: GNU General Public License v2.0 | 3 votes |
/** * Gets the set of abilities with the given identifier from this * object. Subclasses with complex ability handling should * override this as all prior routines are derived from it. * * @param id The object identifier. * @param fcgot An optional {@code FreeColSpecObjectType} the * ability applies to. * @param turn An optional applicable {@code Turn}. * @return A set of abilities. */ public Stream<Ability> getAbilities(String id, FreeColSpecObjectType fcgot, Turn turn) { FeatureContainer fc = getFeatureContainer(); return (fc == null) ? Stream.<Ability>empty() : fc.getAbilities(id, fcgot, turn); }
Example 19
Source Project: mill File: StreamOps.java License: MIT License | 3 votes |
/** * Given any number of streams, returns distinct values such that the set of * elements in the returned stream are those distinct elements of the first * stream that are not contained in any of the subsequent passed streams. * * @param streams An array of streams * @param <T> All elements in all streams are instances of this single type * @return distinct values of the first stream such that the set of elements * in the returned stream are not contained in any of the subsequent passed streams */ public static <T> Stream<T> difference(Stream<T>... streams) { if(streams.length < 1) { return Stream.empty(); } else if(streams.length < 2) { return streams[0]; } else { return difference(streams[0], concat(Arrays.copyOfRange(streams, 1, streams.length - 1))); } }
Example 20
Source Project: freecol File: CollectionUtils.java License: GNU General Public License v2.0 | 3 votes |
/** * Transform the contents of a stream. * * @param <T> The collection member type. * @param <R> The resulting collection member type. * @param <C> The resulting collection type. * @param stream The {@code Stream} to transform. * @param predicate A {@code Predicate} to select the items. * @param mapper A function to transform the selected items. * @param collector A {@code Collector} to aggregate the results. * @return The result of collecting the mapped predicate matches. */ public static <T,R,C> C transform(Stream<T> stream, Predicate<? super T> predicate, Function<? super T, ? extends R> mapper, Collector<R,?,C> collector) { final Stream<T> s = (stream == null) ? Stream.<T>empty() : stream; return transform_internal(s, predicate, mapper, null, collector); }