Package io.micronaut.core.value
Class MapPropertyResolver
- java.lang.Object
-
- io.micronaut.core.value.MapPropertyResolver
-
- All Implemented Interfaces:
PropertyResolver,ValueResolver<java.lang.String>
public class MapPropertyResolver extends java.lang.Object implements PropertyResolver
APropertyResolverthat resolves values from a backing map.- Since:
- 1.0
-
-
Constructor Summary
Constructors Constructor Description MapPropertyResolver(java.util.Map<java.lang.String,java.lang.Object> map)MapPropertyResolver(java.util.Map<java.lang.String,java.lang.Object> map, ConversionService conversionService)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancontainsProperties(java.lang.String name)Whether the given property or any nested properties exist for the key given key within this resolver.booleancontainsProperty(java.lang.String name)Whether the given property is contained within this resolver.<T> java.util.Optional<T>getProperty(java.lang.String name, ArgumentConversionContext<T> conversionContext)Resolve the given property for the given name, type and generic type arguments.java.util.Collection<java.lang.String>getPropertyEntries(java.lang.String name)Returns a collection of properties entries under the given key.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.micronaut.core.value.PropertyResolver
get, getProperties, getProperties, getProperty, getProperty, getProperty, getProperty, getRequiredProperty
-
Methods inherited from interface io.micronaut.core.value.ValueResolver
get, get, get
-
-
-
-
Constructor Detail
-
MapPropertyResolver
public MapPropertyResolver(java.util.Map<java.lang.String,java.lang.Object> map)
- Parameters:
map- The map to resolves the properties from
-
MapPropertyResolver
public MapPropertyResolver(java.util.Map<java.lang.String,java.lang.Object> map, ConversionService conversionService)- Parameters:
map- The map to resolves the properties fromconversionService- The conversion service
-
-
Method Detail
-
containsProperty
public boolean containsProperty(java.lang.String name)
Description copied from interface:PropertyResolverWhether 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:
containsPropertyin interfacePropertyResolver- Parameters:
name- The name of the property- Returns:
- True if it is
-
containsProperties
public boolean containsProperties(java.lang.String name)
Description copied from interface:PropertyResolverWhether the given property or any nested properties exist for the key given key within this resolver.- Specified by:
containsPropertiesin interfacePropertyResolver- Parameters:
name- The name of the property- Returns:
- True if it is
-
getProperty
public <T> java.util.Optional<T> getProperty(java.lang.String name, ArgumentConversionContext<T> conversionContext)Description copied from interface:PropertyResolverResolve 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:
getPropertyin interfacePropertyResolver- Type Parameters:
T- The concrete type- Parameters:
name- The nameconversionContext- The conversion context- Returns:
- An optional containing the property value if it exists
-
getPropertyEntries
@NonNull public java.util.Collection<java.lang.String> getPropertyEntries(@NonNull java.lang.String name)
Description copied from interface:PropertyResolverReturns a collection of properties entries under the given key. For example given the following keys:
Callingdatasource.default.url=localhost datasource.another.url=someothergetPropertyEntries(String)with a value ofdatasourcewill result in a collection containingdefaultandother.- Specified by:
getPropertyEntriesin interfacePropertyResolver- Parameters:
name- The name to resolve- Returns:
- The property entries.
-
-