Class StringToEnumDecoder
- java.lang.Object
-
- com.vaadin.flow.server.communication.rpc.StringToEnumDecoder
-
- All Implemented Interfaces:
RpcDecoder,Serializable
public class StringToEnumDecoder extends Object implements RpcDecoder
Decodes aJsonValuewithJsonType.STRINGtype toEnumsubclass type.This decoder is applicable to any
JsonValuewhich isJsonStringand anyEnumsublcassFor internal use only. May be renamed or removed in a future release.
- Since:
- 1.0
- Author:
- Vaadin Ltd
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description StringToEnumDecoder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> Tdecode(elemental.json.JsonValue value, Class<T> type)Decode the givenvalueto the requiredtype.booleanisApplicable(elemental.json.JsonValue value, Class<?> type)Returnstrueif the decoder is applicable for the givenvalueand the requiredtype.
-
-
-
Method Detail
-
isApplicable
public boolean isApplicable(elemental.json.JsonValue value, Class<?> type)Description copied from interface:RpcDecoderReturnstrueif the decoder is applicable for the givenvalueand the requiredtype.- Specified by:
isApplicablein interfaceRpcDecoder- Parameters:
value- the value which needs to be decodedtype- the required type to decode- Returns:
trueif this decoder is able to decode thevalueto thetype,falseotherwise
-
decode
public <T> T decode(elemental.json.JsonValue value, Class<T> type) throws RpcDecodeExceptionDescription copied from interface:RpcDecoderDecode the givenvalueto the requiredtype.RpcDecodeExceptionis thrown if thevaluecannot be converted to thetype(even though the decoder is applicable for thevalueand thetype).- Specified by:
decodein interfaceRpcDecoder- Type Parameters:
T- the decoded value type- Parameters:
value- the value which needs to be decodedtype- the required type to decode- Returns:
- the decoded value
- Throws:
RpcDecodeException- if thevaluecannot be converted to thetype
-
-