Java Code Examples for one.util.streamex.StreamEx#of()

The following examples show how to use one.util.streamex.StreamEx#of() . 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 File: JsonReader.java    From test-data-supplier with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
public StreamEx<T> read() {
    var gson = new Gson();
    try (var streamReader = new InputStreamReader(getUrl().openStream(), StandardCharsets.UTF_8);
         var jsonReader = new com.google.gson.stream.JsonReader(streamReader)) {
        return StreamEx.of((T[]) Match(parseReader(jsonReader)).of(
            Case($(JsonElement::isJsonArray), j -> gson.fromJson(j, castToArray(entityClass))),
            Case($(), j -> (T[]) new Object[] {gson.fromJson(j, castToObject(entityClass))})
        ));
    } catch (IOException ex) {
        throw new IllegalArgumentException(
            format("Unable to read CSV data to %s. Check provided path.", entityClass), ex);
    }
}
 
Example 2
Source File: YamlReader.java    From test-data-supplier with Apache License 2.0 5 votes vote down vote up
public StreamEx<T> read() {
    try {
        var yamlFactory = new YAMLFactory();
        return StreamEx.of(new ObjectMapper(yamlFactory)
            .configure(FAIL_ON_UNKNOWN_PROPERTIES, false)
            .readValues(yamlFactory.createParser(getUrl()), entityClass)
            .readAll());
    } catch (Exception ex) {
        throw new IllegalArgumentException(format("Unable to read YAML data to %s.", entityClass), ex);
    }
}
 
Example 3
Source File: StreamsDataSupplierTests.java    From test-data-supplier with Apache License 2.0 4 votes vote down vote up
@DataSupplier(flatMap = true)
public StreamEx getInternallyExtractedStreamData() {
    return StreamEx.of(asList("name1", "password1"), asList("name2", "password2"));
}
 
Example 4
Source File: ExternalDataSuppliers.java    From test-data-supplier with Apache License 2.0 4 votes vote down vote up
@DataSupplier(flatMap = true)
public StreamEx externalHashes() {
    return StreamEx.of(Tuple.of("hash1", "password1"), Tuple.of("hash2", "password2"));
}
 
Example 5
Source File: GamaSpatialMatrix.java    From gama with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Stream<G> stream() {
	return (Stream<G>) StreamEx.of(matrix);
}
 
Example 6
Source File: GamaSpatialMatrix.java    From gama with GNU General Public License v3.0 4 votes vote down vote up
@Override
public StreamEx<G> stream(final IScope scope) {
	return (StreamEx<G>) StreamEx.of(matrix);
}
 
Example 7
Source File: GamaSpatialMatrix.java    From gama with GNU General Public License v3.0 4 votes vote down vote up
@Override
public StreamEx<IShape> stream(final IScope scope) {
	return StreamEx.of(matrix);
}
 
Example 8
Source File: GamaObjectMatrix.java    From gama with GNU General Public License v3.0 4 votes vote down vote up
@Override
public StreamEx<Object> stream(final IScope scope) {
	return StreamEx.of(matrix);
}
 
Example 9
Source File: GamaList.java    From gama with GNU General Public License v3.0 4 votes vote down vote up
@Override
public StreamEx<E> stream(final IScope scope) {
	return StreamEx.<E> of(this);
}
 
Example 10
Source File: GamaGraph.java    From gama with GNU General Public License v3.0 4 votes vote down vote up
@Override
public StreamEx<E> stream(final IScope scope) {
	return StreamEx.<E> of(edgeSet());
}
 
Example 11
Source File: IContainer.java    From gama with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Internal method to get a correct stream in order to reuse the algorithms of the Java Collections Framework. The
 * intent is to reduce to the minimum the amount of computation needed in that case. The default is to return the
 * stream of the underlying collection when the container is already a collection. Must be redefined in subclasses.
 *
 * @param scope
 * @return
 */
@SuppressWarnings ("unchecked")
default StreamEx<ValueType> stream(final IScope scope) {
	if (this instanceof Collection) { return StreamEx.of(((Collection<ValueType>) this).stream()); }
	return StreamEx.of(listValue(scope, Types.NO_TYPE, false));
}