Interface ConvertibleValues<V>

Type Parameters:
V - The generic value
All Superinterfaces:
ConversionServiceProvider, Iterable<Map.Entry<String,V>>, ValueResolver<CharSequence>
All Known Subinterfaces:
BeanElementVisitorContext, ConvertibleMultiValues<V>, Cookies, Headers, HttpHeaders, HttpParameters, MessageHeaders, MutableConvertibleMultiValues<V>, MutableConvertibleValues<V>, MutableHeaders, MutableHttpHeaders, MutableHttpParameters, VisitorContext, WebSocketSession
All Known Implementing Classes:
CaseInsensitiveMutableHttpHeaders, ConvertibleMultiValuesMap, ConvertibleValuesMap, GroovyVisitorContext, HttpHeadersAdapter, JavaVisitorContext, JsonNodeConvertibleValues, MutableConvertibleMultiValuesMap, MutableConvertibleValuesMap, NettyCookies, NettyHttpHeaders, NettyHttpParameters, NettyWebSocketSession, ObjectNodeConvertibleValues, SimpleCookies, SimpleHttpHeaders, SimpleHttpParameters

public interface ConvertibleValues<V> extends ValueResolver<CharSequence>, Iterable<Map.Entry<String,V>>, ConversionServiceProvider
An interface for classes that represent a map-like structure of values that can be converted.
Since:
1.0
Author:
Graeme Rocher
  • Field Details

  • Method Details

    • names

      Set<String> names()
      Returns:
      The names of the values
    • values

      Collection<V> values()
      Returns:
      The values
    • isEmpty

      default boolean isEmpty()
      Returns:
      Whether this values is empty
    • getValueType

      default Class<V> getValueType()
      Returns:
      The concrete type of the value
    • contains

      default boolean contains(String name)
      Whether the given key is contained within these values.
      Parameters:
      name - The key name
      Returns:
      True if it is
    • getValue

      @Nullable default V getValue(CharSequence name)
      Get a raw value without any conversion.
      Parameters:
      name - The key name
      Returns:
      True if it is
      Since:
      2.0.0
    • forEach

      default void forEach(BiConsumer<String,V> action)
      Performs the given action for each value. Note that in the case where multiple values exist for the same header then the consumer will be invoked multiple times for the same key.
      Parameters:
      action - The action to be performed for each entry
      Throws:
      NullPointerException - if the specified action is null
      Since:
      1.0
    • asMap

      default Map<String,V> asMap()
      Return this ConvertibleValues as a map for the given key type and value type. The map represents a copy of the data held by this instance.
      Returns:
      The values
    • asMap

      default <KT, VT> Map<KT,VT> asMap(Class<KT> keyType, Class<VT> valueType)
      Return this ConvertibleValues as a map for the given key type and value type. If any entry cannot be converted to the target key/value type then the entry is simply excluded, hence the size of the map returned may not match the size of this ConvertibleValues.
      Type Parameters:
      KT - The key type
      VT - The value type
      Parameters:
      keyType - The key type
      valueType - The value type
      Returns:
      The values with the key converted to the given key type and the value to the given value type.
    • asProperties

      default Properties asProperties()
      Return this ConvertibleValues as a Properties object returning only keys and values that can be represented as a string.
      Returns:
      The values with the key converted to the given key type and the value to the given value type.
      Since:
      1.0.3
    • subMap

      default Map<String,V> subMap(String prefix, Class<V> valueType)
      Returns a submap for all the keys with the given prefix.
      Parameters:
      prefix - The prefix
      valueType - The value type
      Returns:
      The submap
    • subMap

      default Map<String,V> subMap(String prefix, Argument<V> valueType)
      Returns a submap for all the keys with the given prefix.
      Parameters:
      prefix - The prefix
      valueType - The value type
      Returns:
      The submap
    • subMap

      default Map<String,V> subMap(String prefix, ArgumentConversionContext<V> valueType)
      Returns a submap for all the keys with the given prefix.
      Parameters:
      prefix - The prefix
      valueType - The value type
      Returns:
      The submap
    • iterator

      default Iterator<Map.Entry<String,V>> iterator()
      Specified by:
      iterator in interface Iterable<V>
    • of

      static <T> ConvertibleValues<T> of(Map<? extends CharSequence,T> values)
      Creates a new ConvertibleValues for the values.
      Type Parameters:
      T - The target generic type
      Parameters:
      values - A map of values
      Returns:
      The values
    • of

      static <T> ConvertibleValues<T> of(Map<? extends CharSequence,T> values, ConversionService conversionService)
      Creates a new ConvertibleValues for the values.
      Type Parameters:
      T - The target generic type
      Parameters:
      values - A map of values
      conversionService - The conversion service
      Returns:
      The values
      Since:
      4.0.0
    • empty

      static <V> ConvertibleValues<V> empty()
      Type Parameters:
      V - The generic type
      Returns:
      The empty ConvertibleValues
    • getConversionService

      default ConversionService getConversionService()
      Description copied from interface: ConversionServiceProvider
      Provides the conversion service.
      Specified by:
      getConversionService in interface ConversionServiceProvider
      Returns:
      the conversion service