You're viewing an older version of Vaadin JavaDoc. Please see version 24.7.0 for the latest.
com.vaadin.flow.server.communication.rpc.

Class StringToNumberDecoder

  • java.lang.Object
    • com.vaadin.flow.server.communication.rpc.StringToNumberDecoder
  • All Implemented Interfaces:

    RpcDecoder, Serializable

    public class StringToNumberDecoder
    extends Object
    implements RpcDecoder

    Decodes a JsonValue with JsonType.STRING type to Number subclass type.

    This decoder is applicable to any JsonValue which is JsonString and any primitive type wrapper Number subclass (like Integer, Double, Long, etc.).

    For internal use only. May be renamed or removed in a future release.

    Since:

    1.0

    Author:

    Vaadin Ltd

    See Also:

    Serialized Form

    • Constructor Detail

      • StringToNumberDecoder

        public StringToNumberDecoder()
    • Method Detail

      • isApplicable

        public boolean isApplicable​(elemental.json.JsonValue value,
                                    Class<?> type)

        Description copied from interface: RpcDecoder

        Returns true if the decoder is applicable for the given value and the required type.

        Specified by:

        isApplicable in interface RpcDecoder

        Parameters:

        value - the value which needs to be decoded

        type - the required type to decode

        Returns:

        true if this decoder is able to decode the value to the type, false otherwise

      • decode

        public <T> T decode​(elemental.json.JsonValue value,
                            Class<T> type)
                     throws RpcDecodeException

        Description copied from interface: RpcDecoder

        Decode the given value to the required type.

        RpcDecodeException is thrown if the value cannot be converted to the type (even though the decoder is applicable for the value and the type).

        Specified by:

        decode in interface RpcDecoder

        Type Parameters:

        T - the decoded value type

        Parameters:

        value - the value which needs to be decoded

        type - the required type to decode

        Returns:

        the decoded value

        Throws:

        RpcDecodeException - if the value cannot be converted to the type