/*
Construct a new Stream from another Stream

@param s Stream to copy
@param org ignored for LazyFutureStreams
@return
@see com.oath.cyclops.react.stream.BaseSimpleReact#construct(java.util.stream.Stream, java.util.List)
424960
public <U> FutureStream<U> construct(final Stream<U> s) {

        return new FutureStreamImpl<U>(
                                           this, s);

    }
1239149
@Task(name = "createStream", version = "1.0", resource = "{scope}/{stream}")
    public CompletableFuture<CreateStreamStatus.Status> createStream(String scope, String stream, StreamConfiguration config, long createTimestamp) {
        return execute(
                new Resource(scope, stream),
                new Serializable[]{scope, stream, config, createTimestamp},
                () -> createStreamBody(scope, stream, config, createTimestamp));
    }
198171
public static void serializeAsStream(Object o, OutputStream s) throws IOException {
        try {
            JsonStructure builtJsonObject = findFieldsToSerialize(o).mainObject;
            Map<String, Object> config = new HashMap<String, Object>();
            config.put(JsonGenerator.PRETTY_PRINTING, true);
            JsonWriterFactory writerFactory = Json.createWriterFactory(config);
            JsonWriter streamWriter = writerFactory.createWriter(s);
            streamWriter.write(builtJsonObject);
        } catch (IllegalStateException ise) {
            // the reflective attempt to build the object failed.
            throw new IOException("Unable to build JSON for Object", ise);
        } catch (JsonException e) {
            throw new IOException("Unable to build JSON for Object", e);
        }
    }
283909
private static boolean isStreamApiInvocationOnStreamSource(
      @Nullable ExpressionTree rootTree,
      ExpressionTree streamSourceExpression,
      VisitorState visitorState) {
    ExpressionTree expressionTree = rootTree;
    while (STREAM_API_INVOCATION_MATCHER.matches(expressionTree, visitorState)) {
      expressionTree = ASTHelpers.getReceiver(expressionTree);
    }

    if (!COLLECTION_TO_STREAM_MATCHER.matches(expressionTree, visitorState)) {
      return false;
    }

    return isSameExpression(ASTHelpers.getReceiver(expressionTree), streamSourceExpression);
  }
266750
def create_stream(name, **header):
    
    assert isinstance(name, basestring), name
    return CreateStream(parent=None, name=name, group=False, header=header)
350597
public static XMLDocument create(XMLStreamEventsSync stream) throws XMLException, IOException {
		XMLDocument doc = new XMLDocument();
		do {
			switch (stream.event.type) {
			case DOCTYPE:
				if (doc.docType != null)
					throw new XMLException(stream.getPosition(), "Unexpected element ", "DOCTYPE");
				doc.docType = new XMLDocumentType(doc, stream.event.text.asString(),
					stream.event.publicId != null ? stream.event.publicId.asString() : null,
					stream.event.system != null ? stream.event.system.asString() : null);
				break;
			case START_ELEMENT:
				if (doc.root != null)
					throw new XMLException(stream.getPosition(), "Unexpected element ", stream.event.text.asString());
				doc.root = XMLElement.create(doc, stream);
				break;
			default: break;
			}
			try { stream.next(); }
			catch (EOFException e) {
				break;
			}
		} while (true);
		return doc;
	}
367387
@Override
    public java.util.concurrent.Future<CreateStreamResult> createStreamAsync(String streamName, Integer shardCount) {

        return createStreamAsync(new CreateStreamRequest().withStreamName(streamName).withShardCount(shardCount));
    }
984324
public static void copyStream(InputStream is, OutputStream os) 
	throws IOException {
		copyStream(is,os,BUFFER_SIZE);
	}
105909
@Override
  public <T> Streamlet<T> applyOperator(IStreamletOperator<R, T> operator) {
    checkNotNull(operator, "operator cannot be null");

    // By default, NoneStreamGrouping stategy is used. In this stategy, tuples are forwarded
    // from parent component to a ramdon one of all the instances of the child component,
    // which is the same logic as shuffle grouping.
    return applyOperator(operator, new NoneStreamGrouping());
  }
802800
public static <T> Stream<T> create(final Enumeration<? extends T> enumeration) {
        if (enumeration.hasMoreElements()) {
            return new IteratorStream<T>(Iterators.forEnumeration(enumeration));
        } else {
            return new EmptyStream<T>();
        }
    }
993011
public static <K, V> StreamableHashMap<K, V> newMap (Map<? extends K, ? extends V> map)
    {
        return new StreamableHashMap<K, V>(map);
    }
600925
public static StreamSpecifier stream(StreamSpecifierType type, int index) {
    checkNotNull(type);
    return new StreamSpecifier(type.toString() + ":" + index);
  }
121681
public static Stream<?> buildStream(Object object) {
        if (object instanceof Collection)
            return ((Collection<?>) object).stream();
        else if (object.getClass().isArray())
            return Arrays.stream((Object[]) object);
        else
            return Stream.of(object);
    }
521613
public static Stream<Element> stream(Element element) {
        return StreamSupport.stream(new ElementParentsIterable(element).spliterator(), false);
    }
584534
public static <T extends ContentMeta> T withStream(InputStream source, Map<String, String> meta,
            ContentFactory<T> factory) {
        return factory.create(lazyStream(source), meta);
    }
982705
protected synchronized void setStream(InputStream s)
    {
        if (stream != null)
        {
            throw new UnsupportedOperationException("Cannot set the stream of an open resource");
        }
        stream = s;
        streamState = StreamStates.OPEN;
    }
631948
function appendStream(streams, s) {
    assert.arrayOfObject(streams, 'streams');
    assert.object(s, 'stream');

    if (s instanceof Stream) {
        streams.push({
            raw: false,
            stream: s
        });
    } else {
        assert.optionalBool(s.raw, 'stream.raw');
        assert.object(s.stream, 'stream.stream');
        streams.push(s);
    }
}