Skip to content

Commit d6a027c

Browse files
committed
update javdoc
1 parent 0069220 commit d6a027c

3 files changed

Lines changed: 32 additions & 14 deletions

File tree

coverage-report/src/test/java/org/jooby/ws/WebSocketPauseResumeFeature.java

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,6 @@ public class WebSocketPauseResumeFeature extends ServerFeature {
2727
{
2828
ws("/ws", ws -> {
2929
CountDownLatch latch = new CountDownLatch(1);
30-
ws.onMessage(message -> {
31-
32-
ws.send("=" + message.value(), () -> {
33-
latch.await();
34-
ws.close();
35-
});
36-
37-
});
3830

3931
ws.pause();
4032
// 2nd ignored
@@ -46,6 +38,16 @@ public class WebSocketPauseResumeFeature extends ServerFeature {
4638
ws.resume();
4739
latch.countDown();
4840
}, 1, TimeUnit.SECONDS);
41+
42+
ws.onMessage(message -> {
43+
44+
ws.send("=" + message.value(), () -> {
45+
latch.await();
46+
ws.close();
47+
});
48+
49+
});
50+
4951
});
5052

5153
}

jooby/src/main/java/org/jooby/Mutant.java

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,22 +31,27 @@
3131

3232
/**
3333
* <p>
34-
* A type safe {@link Mutant} useful for reading parameters and headers. It let you retrieve a
35-
* HTTP value: <code>param</code> or <code>header</code> in a type safe manner.
34+
* A type safe {@link Mutant} useful for reading parameters and headers.
3635
* </p>
3736
*
3837
* <pre>
38+
* // str param
39+
* String value = request.param("str").value();
40+
*
41+
* // optional str
42+
* String value = request.param("str").toOptional().orElse("defs");
43+
*
3944
* // int param
40-
* int value = request.param("some").getInt();
45+
* int value = request.param("some").intValue();
4146
*
4247
* // optional int param
43-
* Optional{@literal <}Integer{@literal >} value = request.param("some").getOptional(Integer.class);
48+
* Optional{@literal <}Integer{@literal >} value = request.param("some").toOptional(Integer.class);
4449
4550
* // list param
46-
* List{@literal <}String{@literal >} values = request.param("some").getList(String.class);
51+
* List{@literal <}String{@literal >} values = request.param("some").toList(String.class);
4752
*
4853
* // file upload
49-
* Upload upload = request.param("file").get(Upload.class);
54+
* Upload upload = request.param("file").to(Upload.class);
5055
* </pre>
5156
*
5257
* @author edgar
@@ -153,6 +158,13 @@ default <T extends Comparable<T>> SortedSet<T> toSortedSet(@Nonnull final Class<
153158
));
154159
}
155160

161+
/**
162+
* @return An optional string value.
163+
*/
164+
default Optional<String> toOptional() {
165+
return toOptional(String.class);
166+
}
167+
156168
/**
157169
* @param type The optional type.
158170
* @param <T> Optional type.

jooby/src/test/java/org/jooby/internal/MutantImplTest.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,11 @@ public void asStringSortedSet() throws Exception {
461461
public void asOptionalString() throws Exception {
462462
assertEquals(Optional.empty(), newMutant((String) null).toOptional(String.class));
463463

464+
assertEquals(Optional.empty(), newMutant((String) null).toOptional());
465+
464466
assertEquals(Optional.of("A"), newMutant("A").toOptional(String.class));
467+
468+
assertEquals(Optional.of("A"), newMutant("A").toOptional());
465469
}
466470

467471
@Test

0 commit comments

Comments
 (0)