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 boolean |
booleanValue(boolean value) |
default byte |
byteValue() |
default byte |
byteValue(int value) |
default char |
charValue() |
default char |
charValue(char value) |
default double |
doubleValue() |
default double |
doubleValue(double value) |
default float |
floatValue() |
default float |
floatValue(float value) |
default int |
intValue() |
default int |
intValue(int value) |
boolean |
isSet() |
default long |
longValue() |
default long |
longValue(long value) |
default short |
shortValue() |
default short |
shortValue(int value) |
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 <T extends Enum<T>> |
toEnum(T value) |
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 String |
value(String value) |
default boolean booleanValue()
default boolean booleanValue(boolean value)
value
- Default value to use.default byte byteValue()
default byte byteValue(int value)
value
- Default value to use.default char charValue()
default char charValue(char value)
value
- Default value to use.default short shortValue()
default short shortValue(int value)
value
- Default value to use.default int intValue()
default int intValue(int value)
value
- Default value to use.default long longValue()
default long longValue(long value)
value
- Default value to use.default String value()
default String value(String value)
value
- Default value to use.default float floatValue()
default float floatValue(float value)
value
- Default value to use.default double doubleValue()
default double doubleValue(double value)
value
- Default value to use.default <T extends Enum<T>> T toEnum(Class<T> type)
T
- Enum type.type
- The enum type.default <T extends Enum<T>> T toEnum(T value)
T
- Enum type.value
- Default value to use.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
.boolean isSet()
Copyright © 2016. All rights reserved.