Skip to content

Commit 4dcc96c

Browse files
committed
value api: remove @EmptyBean annotation and make QueryString.toNullable truly nullable
- Add `QueryString.toEmpty` for backwards compatibility
1 parent 05d8953 commit 4dcc96c

File tree

18 files changed

+302
-224
lines changed

18 files changed

+302
-224
lines changed

jooby/src/main/java/io/jooby/Body.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public interface Body extends Value {
4040
* @param charset Charset.
4141
* @return Body as string.
4242
*/
43-
default @NonNull String value(@NonNull Charset charset) {
43+
default String value(@NonNull Charset charset) {
4444
byte[] bytes = bytes();
4545
if (bytes.length == 0) {
4646
throw new MissingValueException("body");
@@ -95,30 +95,30 @@ default Iterator<Value> iterator() {
9595
*
9696
* @return Body as readable channel.
9797
*/
98-
@NonNull ReadableByteChannel channel();
98+
ReadableByteChannel channel();
9999

100100
/**
101101
* Body as input stream.
102102
*
103103
* @return Body as input stream.
104104
*/
105-
@NonNull InputStream stream();
105+
InputStream stream();
106106

107-
@NonNull @Override
107+
@Override
108108
default <T> List<T> toList(@NonNull Class<T> type) {
109109
return to(Reified.list(type).getType());
110110
}
111111

112-
default @NonNull @Override List<String> toList() {
112+
default @Override List<String> toList() {
113113
return List.of(value());
114114
}
115115

116-
default @NonNull @Override Set<String> toSet() {
116+
default @Override Set<String> toSet() {
117117
return Set.of(value());
118118
}
119119

120120
@Override
121-
default @NonNull <T> T to(@NonNull Class<T> type) {
121+
default <T> T to(@NonNull Class<T> type) {
122122
return to((Type) type);
123123
}
124124

@@ -133,7 +133,7 @@ default <T> List<T> toList(@NonNull Class<T> type) {
133133
* @param <T> Generic type.
134134
* @return Converted value.
135135
*/
136-
@NonNull <T> T to(@NonNull Type type);
136+
<T> T to(@NonNull Type type);
137137

138138
/**
139139
* Convert this body into the given type.
@@ -155,7 +155,7 @@ default <T> List<T> toList(@NonNull Class<T> type) {
155155
* @param ctx Current context.
156156
* @return Empty body.
157157
*/
158-
static @NonNull Body empty(@NonNull Context ctx) {
158+
static Body empty(@NonNull Context ctx) {
159159
return ByteArrayBody.empty(ctx);
160160
}
161161

@@ -167,7 +167,7 @@ default <T> List<T> toList(@NonNull Class<T> type) {
167167
* @param size Size in bytes or <code>-1</code>.
168168
* @return A new body.
169169
*/
170-
static @NonNull Body of(@NonNull Context ctx, @NonNull InputStream stream, long size) {
170+
static Body of(@NonNull Context ctx, @NonNull InputStream stream, long size) {
171171
return new InputStreamBody(ctx, stream, size);
172172
}
173173

@@ -178,7 +178,7 @@ default <T> List<T> toList(@NonNull Class<T> type) {
178178
* @param bytes byte array.
179179
* @return A new body.
180180
*/
181-
static @NonNull Body of(@NonNull Context ctx, @NonNull byte[] bytes) {
181+
static Body of(@NonNull Context ctx, @NonNull byte[] bytes) {
182182
return new ByteArrayBody(ctx, bytes);
183183
}
184184

@@ -189,7 +189,7 @@ default <T> List<T> toList(@NonNull Class<T> type) {
189189
* @param file File.
190190
* @return A new body.
191191
*/
192-
static @NonNull Body of(@NonNull Context ctx, @NonNull Path file) {
192+
static Body of(@NonNull Context ctx, @NonNull Path file) {
193193
return new FileBody(ctx, file);
194194
}
195195
}

0 commit comments

Comments
 (0)