public interface PropertyResolver extends ValueResolver<String>
Modifier and Type | Method and Description |
---|---|
boolean |
containsProperties(String name)
Whether the given property or any nested properties exist for the key given key within this resolver.
|
boolean |
containsProperty(String name)
Whether the given property is contained within this resolver.
|
default <T> Optional<T> |
get(String name,
ArgumentConversionContext<T> conversionContext)
Resolve the given property for the given name.
|
default Map<String,Object> |
getProperties(String name)
Return all the properties under the given key.
|
default Map<String,Object> |
getProperties(String name,
StringConvention keyFormat)
Return all the properties under the given key.
|
default <T> Optional<T> |
getProperty(String name,
Argument<T> argument)
Resolve the given property for the given name, type and generic type arguments.
|
<T> Optional<T> |
getProperty(String name,
ArgumentConversionContext<T> conversionContext)
Resolve the given property for the given name, type and generic type arguments.
|
default <T> Optional<T> |
getProperty(String name,
Class<T> requiredType)
Resolve the given property for the given name.
|
default <T> Optional<T> |
getProperty(String name,
Class<T> requiredType,
ConversionContext context)
Resolve the given property for the given name, type and generic type arguments.
|
default <T> T |
getProperty(String name,
Class<T> requiredType,
T defaultValue)
Resolve the given property for the given name.
|
default Collection<String> |
getPropertyEntries(String name)
Returns a collection of properties entries under the given key.
|
default <T> T |
getRequiredProperty(String name,
Class<T> requiredType)
Resolve the given property for the given name.
|
static String |
nameOf(String... path)
Builds a property name for the given property path.
|
get, get, get
boolean containsProperty(@NonNull String name)
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 containsProperties(String)
instead.
name
- The name of the propertyboolean containsProperties(@NonNull String name)
name
- The name of the property@NonNull <T> Optional<T> getProperty(@NonNull String name, @NonNull ArgumentConversionContext<T> conversionContext)
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.
T
- The concrete typename
- The nameconversionContext
- The conversion context@NonNull default Collection<String> getPropertyEntries(@NonNull String name)
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
.name
- The name to resolve@NonNull default <T> Optional<T> getProperty(@NonNull String name, @NonNull Argument<T> argument)
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.
T
- The concrete typename
- The nameargument
- The required type@NonNull default Map<String,Object> getProperties(@NonNull String name)
name
- The name@NonNull default Map<String,Object> getProperties(@Nullable String name, @Nullable StringConvention keyFormat)
StringConvention.RAW
.name
- The namekeyFormat
- The key format to use for the keys. Default is kebab-case.@NonNull default <T> Optional<T> getProperty(@NonNull String name, @NonNull Class<T> requiredType, @NonNull ConversionContext context)
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.
T
- The concrete typename
- The namerequiredType
- The required typecontext
- The ConversionContext
to apply to any conversion@NonNull default <T> Optional<T> get(@NonNull String name, @NonNull ArgumentConversionContext<T> conversionContext)
ValueResolver
get
in interface ValueResolver<String>
T
- The concrete typename
- The nameconversionContext
- The conversion context@NonNull default <T> Optional<T> getProperty(@NonNull String name, @NonNull Class<T> requiredType)
T
- The concrete typename
- The namerequiredType
- The required type@Nullable default <T> T getProperty(@NonNull String name, @NonNull Class<T> requiredType, @Nullable T defaultValue)
T
- The concrete typename
- The namerequiredType
- The required typedefaultValue
- The default value@NonNull default <T> T getRequiredProperty(@NonNull String name, @NonNull Class<T> requiredType) throws PropertyNotFoundException
T
- The concrete typename
- The name of the propertyrequiredType
- The required typePropertyNotFoundException
- exception when property does not exist