接口 PropertyResolver

所有已知子接口:
ConfigurableEnvironment, ConfigurablePropertyResolver, Environment, IterablePropertyResolver
所有已知实现类:
AbstractEnvironment, AbstractPropertyResolver, MapPropertyResolver, PropertiesPropertyResolver, PropertySourcesPropertyResolver, StandardEnvironment, TypedPropertyResolver

public interface PropertyResolver
Interface for resolving properties against any underlying source.
从以下版本开始:
4.0
作者:
Chris Beams, Juergen Hoeller, Harry Yang
另请参阅:
  • 方法概要

    修饰符和类型
    方法
    说明
    boolean
    Return whether the given property key is available for resolution, i.e. if the value for the given key is not null.
    default boolean
    Retrieve the flag for the given property key.
    default boolean
    getFlag(String key, boolean defaultFlag)
    Retrieve the flag for the given property key.
    Return the property value associated with the given key, or null if the key cannot be resolved.
    <T> T
    getProperty(String key, Class<T> targetType)
    Return the property value associated with the given key, or null if the key cannot be resolved.
    <T> T
    getProperty(String key, Class<T> targetType, T defaultValue)
    Return the property value associated with the given key, or defaultValue if the key cannot be resolved.
    getProperty(String key, String defaultValue)
    Return the property value associated with the given key, or defaultValue if the key cannot be resolved.
    Return the property value associated with the given key (never null).
    <T> T
    getRequiredProperty(String key, Class<T> targetType)
    Return the property value associated with the given key, converted to the given targetType (never null).
    Resolve ${...} placeholders in the given text, replacing them with corresponding property values as resolved by getProperty(java.lang.String).
    Resolve ${...} placeholders in the given text, replacing them with corresponding property values as resolved by getProperty(java.lang.String).
  • 方法详细资料

    • containsProperty

      boolean containsProperty(String key)
      Return whether the given property key is available for resolution, i.e. if the value for the given key is not null.
    • getProperty

      @Nullable String getProperty(String key)
      Return the property value associated with the given key, or null if the key cannot be resolved.
      参数:
      key - the property name to resolve
      另请参阅:
    • getProperty

      String getProperty(String key, String defaultValue)
      Return the property value associated with the given key, or defaultValue if the key cannot be resolved.
      参数:
      key - the property name to resolve
      defaultValue - the default value to return if no value is found
      另请参阅:
    • getProperty

      @Nullable <T> T getProperty(String key, Class<T> targetType)
      Return the property value associated with the given key, or null if the key cannot be resolved.
      参数:
      key - the property name to resolve
      targetType - the expected type of the property value
      另请参阅:
    • getProperty

      <T> T getProperty(String key, Class<T> targetType, T defaultValue)
      Return the property value associated with the given key, or defaultValue if the key cannot be resolved.
      参数:
      key - the property name to resolve
      targetType - the expected type of the property value
      defaultValue - the default value to return if no value is found
      另请参阅:
    • getRequiredProperty

      String getRequiredProperty(String key) throws IllegalStateException
      Return the property value associated with the given key (never null).
      抛出:
      IllegalStateException - if the key cannot be resolved
      另请参阅:
    • getRequiredProperty

      <T> T getRequiredProperty(String key, Class<T> targetType) throws IllegalStateException
      Return the property value associated with the given key, converted to the given targetType (never null).
      抛出:
      IllegalStateException - if the given key cannot be resolved
    • getFlag

      default boolean getFlag(String key)
      Retrieve the flag for the given property key.

      Returns false if key not found

      参数:
      key - the property key
      返回:
      true if the property is set to "true", false otherwise
    • getFlag

      default boolean getFlag(String key, boolean defaultFlag)
      Retrieve the flag for the given property key.

      If there isn't a key returns defaultFlag

      参数:
      key - the property key
      defaultFlag - default return value if key not found
      返回:
      true if the property is set to "true", false otherwise ,If there isn't a key returns defaultFlag
    • resolvePlaceholders

      String resolvePlaceholders(String text)
      Resolve ${...} placeholders in the given text, replacing them with corresponding property values as resolved by getProperty(java.lang.String). Unresolvable placeholders with no default value are ignored and passed through unchanged.
      参数:
      text - the String to resolve
      返回:
      the resolved String (never null)
      抛出:
      IllegalArgumentException - if given text is null
      另请参阅:
    • resolveRequiredPlaceholders

      String resolveRequiredPlaceholders(String text) throws IllegalArgumentException
      Resolve ${...} placeholders in the given text, replacing them with corresponding property values as resolved by getProperty(java.lang.String). Unresolvable placeholders with no default value will cause an IllegalArgumentException to be thrown.
      返回:
      the resolved String (never null)
      抛出:
      IllegalArgumentException - if given text is null or if any placeholders are unresolvable