Created
March 8, 2017 08:34
-
-
Save adrian-baker/24df92918fb656b0c8b57597de958eff to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Path("/rainbow") | |
public class StreamingResource { | |
@GET | |
@Produces(MediaType.APPLICATION_JSON) | |
public Rainbow getRainbow() { | |
return new Rainbow( | |
IntStream.range(0, Integer.MAX_VALUE).boxed(), | |
IntStream.range(0, Integer.MAX_VALUE).boxed(), | |
IntStream.range(0, Integer.MAX_VALUE).boxed()); | |
} | |
public static class Rainbow { | |
private final Stream<Integer> red; | |
private final Stream<Integer> blue; | |
private final Stream<Integer> green; | |
public Rainbow(Stream<Integer> red, Stream<Integer> blue, Stream<Integer> green) { | |
this.red = red; | |
this.blue = blue; | |
this.green = green; | |
} | |
public Stream<Integer> getRed() { | |
return red; | |
} | |
public Stream<Integer> getBlue() { | |
return blue; | |
} | |
public Stream<Integer> getGreen() { | |
return green; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment