Class MapPropertyResolver

java.lang.Object
io.micronaut.core.value.MapPropertyResolver
All Implemented Interfaces:
PropertyResolver, ValueResolver<String>

public class MapPropertyResolver extends Object implements PropertyResolver
A PropertyResolver that resolves values from a backing map.
Since:
1.0
Author:
Graeme Rocher
  • Constructor Details

    • MapPropertyResolver

      public MapPropertyResolver(Map<String,Object> map)
      Parameters:
      map - The map to resolves the properties from
    • MapPropertyResolver

      public MapPropertyResolver(Map<String,Object> map, ConversionService conversionService)
      Parameters:
      map - The map to resolves the properties from
      conversionService - The conversion service
  • Method Details

    • containsProperty

      public boolean containsProperty(String name)
      Description copied from interface: PropertyResolver

      Whether the given property is contained within this resolver.

      Note that this method will return false for nested properties. In other words given a key of foo.bar this method will return false for: resolver.containsProperty("foo")

      To check for nested properties using PropertyResolver.containsProperties(String) instead.

      Specified by:
      containsProperty in interface PropertyResolver
      Parameters:
      name - The name of the property
      Returns:
      True if it is
    • containsProperties

      public boolean containsProperties(String name)
      Description copied from interface: PropertyResolver
      Whether the given property or any nested properties exist for the key given key within this resolver.
      Specified by:
      containsProperties in interface PropertyResolver
      Parameters:
      name - The name of the property
      Returns:
      True if it is
    • getProperty

      public <T> Optional<T> getProperty(String name, ArgumentConversionContext<T> conversionContext)
      Description copied from interface: PropertyResolver

      Resolve the given property for the given name, type and generic type arguments.

      Implementers can choose to implement more intelligent type conversion by analyzing the typeArgument.

      Specified by:
      getProperty in interface PropertyResolver
      Type Parameters:
      T - The concrete type
      Parameters:
      name - The name
      conversionContext - The conversion context
      Returns:
      An optional containing the property value if it exists
    • getPropertyEntries

      @NonNull public @NonNull Collection<String> getPropertyEntries(@NonNull @NonNull String name)
      Description copied from interface: PropertyResolver
      Returns a collection of properties entries under the given key. For example given the following keys:
      
       datasource.default.url=localhost
       datasource.another.url=someother
       
      Calling getPropertyEntries(String) with a value of datasource will result in a collection containing default and other.
      Specified by:
      getPropertyEntries in interface PropertyResolver
      Parameters:
      name - The name to resolve
      Returns:
      The property entries.
    • getPropertyPathMatches

      public List<List<String>> getPropertyPathMatches(String pathPattern)
      Description copied from interface: PropertyResolver
      Will return for a given pattern such as foo.*.bar.* and array of arrays containing the variable names that match the pattern.
      Specified by:
      getPropertyPathMatches in interface PropertyResolver
      Parameters:
      pathPattern - The path pattern
      Returns:
      An array of arrays.