/* Copyright 2015 Twitter, Inc. */
package com.twitter.io;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.InputStream;
import com.twitter.concurrent.AsyncStream;
import com.twitter.util.Future;
import scala.runtime.BoxedUnit;

/**
 * Java APIs for Reader.
 *
 * @see com.twitter.io.Reader
 */
public final class Readers {

  private Readers() { throw new IllegalStateException(); }

  public static <A> Reader<A> newEmptyReader() {
    return Reader$.MODULE$.<A>empty();
  }

  /**
   * See {@code com.twitter.io.Reader.fromBuf}.
   */
  public static Reader<Buf> newBufReader(Buf buf, int chunkSize) {
    return Reader$.MODULE$.fromBuf(buf, chunkSize);
  }

  /**
   * See {@code com.twitter.io.Reader.readAll}.
   */
  public static Future<Buf> readAll(Reader<Buf> r) {
    return Reader$.MODULE$.readAll(r);
  }

  /**
   * See {@code com.twitter.io.Reader.concat}.
   */
  public static Reader<Buf> concat(AsyncStream<Reader<Buf>> readers) {
    return Reader$.MODULE$.concat(readers);
  }

  /**
   * See {@code com.twitter.io.Reader.copy}.
   */
  public static Future<BoxedUnit> copy(Reader<Buf> r, Writer<Buf> w) {
    return Reader$.MODULE$.copy(r, w);
  }

  /**
   * See {@code com.twitter.io.Reader.copyMany}.
   */
  public static Future<BoxedUnit> copyMany(AsyncStream<Reader<Buf>> readers, Writer<Buf> w) {
    return Reader$.MODULE$.copyMany(readers, w);
  }

  /**
   * See {@code com.twitter.io.Reader.fromFile()}.
   */
  public static Reader<Buf> newFileReader(File f, int chunkSize) throws FileNotFoundException {
    return Reader$.MODULE$.fromFile(f, chunkSize);
  }

  /**
   * See {@code com.twitter.io.Reader.fromStream()}.
   */
  public static Reader<Buf> newInputStreamReader(InputStream in, int chunkSize) {
    return Reader$.MODULE$.fromStream(in, chunkSize);
  }

}

@@ -132,32 +132,88 @@
 io.InputStream;%0A
+import java.util.List;%0Aimport java.util.stream.Stream;%0A%0A
 import com.twitt
@@ -270,16 +270,57 @@
 .Future;
+%0A%0Aimport scala.collection.JavaConverters;
 %0Aimport 
@@ -1916,10 +1916,712 @@
 );%0A  %7D%0A%0A
+  /**%0A   * See %5B%5Bcom.twitter.io.Reader$#fromSeq(scala.collection.Seq)%5D%5D%0A   */%0A  public static %3CA%3E Reader%3CA%3E fromSeq(List%3CA%3E list) %7B%0A    return Reader$.MODULE$.fromSeq(JavaConverters.asScalaIteratorConverter(list.iterator())%0A      .asScala().toSeq());%0A  %7D%0A%0A  /**%0A   * See %5B%5Bcom.twitter.io.Reader$#fromSeq(scala.collection.Seq)%5D%5D%0A   */%0A  public static %3CA%3E Reader%3CA%3E fromSeq(Stream%3CA%3E stream) %7B%0A    return Reader$.MODULE$.fromSeq(JavaConverters.asScalaIteratorConverter(stream.iterator())%0A      .asScala().toSeq());%0A  %7D%0A%0A  /**%0A   * See %5B%5Bcom.twitter.io.Reader#toAsyncStream%5D%5D%0A   */%0A  public static %3CA%3E AsyncStream%3CA%3E toAsyncStream(Reader%3CA%3E reader) %7B%0A    return Reader$.MODULE$.toAsyncStream(reader);%0A  %7D%0A
 %7D%0A

Initial draft of StreamingResponse and StreamingRequest