33 * Apache License Version 2.0 https://jooby.io/LICENSE.txt
44 * Copyright 2014 Edgar Espina
55 */
6- package io .jooby .output ;
6+ package io .jooby .internal . output ;
77
88import java .nio .ByteBuffer ;
99import java .nio .charset .Charset ;
1313import edu .umd .cs .findbugs .annotations .NonNull ;
1414import io .jooby .Context ;
1515import io .jooby .SneakyThrows ;
16+ import io .jooby .output .Output ;
1617
17- class ByteBufferOut implements Output {
18+ public class ByteBufferOutput implements Output {
1819 private static final int MAX_CAPACITY = Integer .MAX_VALUE ;
1920
2021 private static final int CAPACITY_THRESHOLD = 1024 * 1024 * 4 ;
@@ -27,20 +28,20 @@ class ByteBufferOut implements Output {
2728
2829 private int writePosition ;
2930
30- public ByteBufferOut (boolean direct , int capacity ) {
31+ public ByteBufferOutput (boolean direct , int capacity ) {
3132 this .buffer = allocate (capacity , direct );
3233 this .capacity = this .buffer .remaining ();
3334 }
3435
35- public ByteBufferOut (boolean direct ) {
36+ public ByteBufferOutput (boolean direct ) {
3637 this (direct , BUFFER_SIZE );
3738 }
3839
39- public ByteBufferOut (int bufferSize ) {
40+ public ByteBufferOutput (int bufferSize ) {
4041 this (false , bufferSize );
4142 }
4243
43- public ByteBufferOut () {
44+ public ByteBufferOutput () {
4445 this (BUFFER_SIZE );
4546 }
4647
@@ -57,12 +58,12 @@ private void ensureWritable(int length) {
5758 }
5859
5960 @ Override
60- public void accept ( SneakyThrows .Consumer <ByteBuffer > consumer ) {
61+ public void transferTo ( @ NonNull SneakyThrows .Consumer <ByteBuffer > consumer ) {
6162 consumer .accept (asByteBuffer ());
6263 }
6364
6465 @ Override
65- public Iterator <ByteBuffer > iterator () {
66+ public @ NonNull Iterator <ByteBuffer > iterator () {
6667 return List .of (asByteBuffer ()).iterator ();
6768 }
6869
@@ -71,7 +72,7 @@ private int writableByteCount() {
7172 }
7273
7374 @ Override
74- public ByteBuffer asByteBuffer () {
75+ public @ NonNull ByteBuffer asByteBuffer () {
7576 return this .buffer .duplicate ().position (this .readPosition ).limit (this .writePosition );
7677 }
7778
0 commit comments