public interface Mutant
A type safe Mutant
useful for reading parameters/headers/session attributes, etc..
// str param String value = request.param("str").value(); // optional str String value = request.param("str").value("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(byte 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(short 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 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(byte 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(short 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.
@Nonnull 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.
@Nonnull default <T extends Enum<T>> T toEnum(Class<T> type)
T
- Enum type.
type
- The enum type.
@Nonnull default <T extends Enum<T>> T toEnum(T value)
T
- Enum type.
value
- Default value to use.
@Nonnull default <T> List<T> toList(Class<T> type)
T
- List type.
type
- The element type.
@Nonnull default <T> Set<T> toSet(Class<T> type)
T
- Set type.
type
- The element type.
@Nonnull default SortedSet<String> toSortedSet()
@Nonnull default <T extends Comparable<T>> SortedSet<T> toSortedSet(Class<T> type)
T
- Set type.
type
- The element type.
@Nonnull default <T> Optional<T> toOptional(Class<T> type)
T
- Optional type.
type
- The optional type.
@Nonnull default <T> T to(Class<T> type)
T
- Target type.
type
- The type to convert to.
@Nonnull <T> T to(com.google.inject.TypeLiteral<T> type)
T
- Target type.
type
- The type to convert to.
@Nonnull 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.
@Nonnull 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.
@Nonnull 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.
@Nonnull <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.
@Nonnull 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 © 2019. All rights reserved.