public interface Mutant
A type safe Mutant
useful for reading parameters and headers.
// str param String value = request.param("str").value(); // optional str String value = request.param("str").toOptional().orElse("defs"); // int param int value = request.param("some").intValue(); // optional int param Optional <Integer > value = request.param("some").toOptional(Integer.class); // list param List <String > values = request.param("some").toList(String.class); // file upload Upload upload = request.param("file").to(Upload.class);
Request.param(String)
,
Request.header(String)
Modifier and Type | Method and Description |
---|---|
default boolean |
booleanValue() |
default byte |
byteValue() |
default char |
charValue() |
default double |
doubleValue() |
default float |
floatValue() |
default int |
intValue() |
default long |
longValue() |
default short |
shortValue() |
default <T> T |
to(Class<T> type)
Convert a raw value to the given type.
|
default <T> T |
to(Class<T> type,
MediaType mtype)
Convert a raw value to the given type.
|
default <T> T |
to(Class<T> type,
String mtype)
Convert a raw value to the given type.
|
<T> T |
to(com.google.inject.TypeLiteral<T> type)
Convert a raw value to the given type.
|
<T> T |
to(com.google.inject.TypeLiteral<T> type,
MediaType mtype)
Convert a raw value to the given type.
|
default <T> T |
to(com.google.inject.TypeLiteral<T> type,
String mtype)
Convert a raw value to the given type.
|
default <T extends Enum<T>> |
toEnum(Class<T> type) |
default List<String> |
toList() |
default <T> List<T> |
toList(Class<T> type) |
Map<String,Mutant> |
toMap()
A map view of this mutant.
|
default Optional<String> |
toOptional() |
default <T> Optional<T> |
toOptional(Class<T> type) |
default Set<String> |
toSet() |
default <T> Set<T> |
toSet(Class<T> type) |
default SortedSet<String> |
toSortedSet() |
default <T extends Comparable<T>> |
toSortedSet(Class<T> type) |
default Upload |
toUpload()
Convert a form field to file
Upload . |
default String |
value() |
default boolean booleanValue()
default byte byteValue()
default char charValue()
default short shortValue()
default int intValue()
default long longValue()
default String value()
default float floatValue()
default double doubleValue()
default <T extends Enum<T>> T toEnum(Class<T> type)
T
- Enum type.type
- The enum type.default <T> List<T> toList(Class<T> type)
T
- List type.type
- The element type.default <T> Set<T> toSet(Class<T> type)
T
- Set type.type
- The element type.default SortedSet<String> toSortedSet()
default <T extends Comparable<T>> SortedSet<T> toSortedSet(Class<T> type)
T
- Set type.type
- The element type.default <T> Optional<T> toOptional(Class<T> type)
T
- Optional type.type
- The optional type.default <T> T to(Class<T> type)
T
- Target type.type
- The type to convert to.<T> T to(com.google.inject.TypeLiteral<T> type)
T
- Target type.type
- The type to convert to.default <T> T to(Class<T> type, String mtype)
MediaType
before
parsing a value, useful if a form field from a HTTP POST was send as json (or any other data).T
- Target type.type
- The type to convert to.mtype
- A media type to hint a parser.default <T> T to(Class<T> type, MediaType mtype)
MediaType
before
parsing a value, useful if a form field from a HTTP POST was send as json (or any other data).T
- Target type.type
- The type to convert to.mtype
- A media type to hint a parser.default <T> T to(com.google.inject.TypeLiteral<T> type, String mtype)
MediaType
before
parsing a value, useful if a form field from a HTTP POST was send as json (or any other data).T
- Target type.type
- The type to convert to.mtype
- A media type to hint a parser.<T> T to(com.google.inject.TypeLiteral<T> type, MediaType mtype)
MediaType
before
parsing a value, useful if a form field from a HTTP POST was send as json (or any other data).T
- Target type.type
- The type to convert to.mtype
- A media type to hint a parser.Map<String,Mutant> toMap()
Request.params()
the resulting map will have all the
available parameter names.
If the mutant is the result of Request.param(String)
the resulting map will have just
one entry, with the name as key.
If the mutant is the result of Request.body()
the resulting map will have just
one entry, with a key of body
.Copyright © 2015. All rights reserved.