Package ratpack.util

Interface TypeCoercingMap<K>

  • Type Parameters:
    K - The type of the keys
    All Superinterfaces:
    java.util.Map<K,​java.lang.String>
    All Known Subinterfaces:
    PathTokens

    public interface TypeCoercingMap<K>
    extends java.util.Map<K,​java.lang.String>
    A string valued map that can do simple type conversions from the string values to primitive types.
    • Nested Class Summary

      • Nested classes/interfaces inherited from interface java.util.Map

        java.util.Map.Entry<K extends java.lang.Object,​V extends java.lang.Object>
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      java.lang.Boolean asBool​(K key)
      Convert the value with given key to a Boolean, using Boolean.valueOf(String).
      java.lang.Byte asByte​(K key)
      Convert the value with given key to a Byte, using Byte.valueOf(String).
      java.lang.Integer asInt​(K key)
      Convert the value with given key to a Integer, using Integer.valueOf(String).
      java.lang.Long asLong​(K key)
      Convert the value with given key to a Long, using Long.valueOf(String).
      java.lang.Short asShort​(K key)
      Convert the value with given key to a Short, using Short.valueOf(String).
      • Methods inherited from interface java.util.Map

        clear, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, equals, forEach, get, getOrDefault, hashCode, isEmpty, keySet, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, values
    • Method Detail

      • asBool

        java.lang.Boolean asBool​(K key)
        Convert the value with given key to a Boolean, using Boolean.valueOf(String).
        Parameters:
        key - The key of the value to convert
        Returns:
        The result of Boolean.valueOf(String) if the value is not null, else null
      • asByte

        java.lang.Byte asByte​(K key)
        Convert the value with given key to a Byte, using Byte.valueOf(String).
        Parameters:
        key - The key of the value to convert
        Returns:
        The result of Byte.valueOf(String) if the value is not null, else null
      • asShort

        java.lang.Short asShort​(K key)
                         throws java.lang.NumberFormatException
        Convert the value with given key to a Short, using Short.valueOf(String).
        Parameters:
        key - The key of the value to convert
        Returns:
        The result of Short.valueOf(String) if the value is not null, else null
        Throws:
        java.lang.NumberFormatException - if the value cannot be coerced
      • asInt

        java.lang.Integer asInt​(K key)
                         throws java.lang.NumberFormatException
        Convert the value with given key to a Integer, using Integer.valueOf(String).
        Parameters:
        key - The key of the value to convert
        Returns:
        The result of Integer.valueOf(String) if the value is not null, else null
        Throws:
        java.lang.NumberFormatException - if the value cannot be coerced
      • asLong

        java.lang.Long asLong​(K key)
                       throws java.lang.NumberFormatException
        Convert the value with given key to a Long, using Long.valueOf(String).
        Parameters:
        key - The key of the value to convert
        Returns:
        The result of Long.valueOf(String) if the value is not null, else null
        Throws:
        java.lang.NumberFormatException - if the value cannot be coerced