类 Hints
- java.lang.Object
- org.springframework.core.codec.Hints
public abstract class Hints extends Object
Constants and convenience methods for working with hints.- 从以下版本开始:
- 5.1
- 作者:
- Rossen Stoyanchev
- 另请参阅:
ResourceRegionEncoder.BOUNDARY_STRING_HINT
字段概要
字段 修饰符和类型 字段 说明 static String
LOG_PREFIX_HINT
Name of hint exposing a prefix to use for correlating log messages.static String
SUPPRESS_LOGGING_HINT
Name of boolean hint whether to avoid logging data either because it's potentially sensitive, or because it has been logged by a composite encoder, e.g. for multipart requests.
构造器概要
构造器 构造器 说明 Hints()
方法概要
所有方法 静态方法 具体方法 修饰符和类型 方法 说明 static Map<String,Object>
from(String hintName, Object value)
Create a map wit a single hint viaCollections.singletonMap(K, V)
.static String
getLogPrefix(Map<String,Object> hints)
Obtain the hintLOG_PREFIX_HINT
, if present, or an empty String.static <T> T
getRequiredHint(Map<String,Object> hints, String hintName)
Obtain the value for a required hint.static boolean
isLoggingSuppressed(Map<String,Object> hints)
Whether to suppress logging based on the hintSUPPRESS_LOGGING_HINT
.static Map<String,Object>
merge(Map<String,Object> hints, String hintName, Object hintValue)
Merge a single hint into a map of hints, possibly creating and copying all hints into a new map, or otherwise if the map of hints is empty, creating a new single entry map.static Map<String,Object>
merge(Map<String,Object> hints1, Map<String,Object> hints2)
Merge two maps of hints, creating and copying into a new map if both have values, or returning the non-empty map, or an empty map if both are empty.static Map<String,Object>
none()
Return an empty map of hints viaCollections.emptyMap()
.
字段详细资料
LOG_PREFIX_HINT
public static final String LOG_PREFIX_HINT
Name of hint exposing a prefix to use for correlating log messages.
SUPPRESS_LOGGING_HINT
public static final String SUPPRESS_LOGGING_HINT
Name of boolean hint whether to avoid logging data either because it's potentially sensitive, or because it has been logged by a composite encoder, e.g. for multipart requests.
构造器详细资料
Hints
public Hints()
方法详细资料
from
public static Map<String,Object> from(String hintName, Object value)
Create a map wit a single hint viaCollections.singletonMap(K, V)
.- 参数:
hintName
- the hint namevalue
- the hint value- 返回:
- the created map
none
public static Map<String,Object> none()
Return an empty map of hints viaCollections.emptyMap()
.- 返回:
- the empty map
getRequiredHint
public static <T> T getRequiredHint(@Nullable Map<String,Object> hints, String hintName)
Obtain the value for a required hint.- 类型参数:
T
- the hint type to cast to- 参数:
hints
- the hints maphintName
- the required hint name- 返回:
- the hint value
- 抛出:
IllegalArgumentException
- if the hint is not found
getLogPrefix
public static String getLogPrefix(@Nullable Map<String,Object> hints)
Obtain the hintLOG_PREFIX_HINT
, if present, or an empty String.- 参数:
hints
- the hints passed to the encode method- 返回:
- the log prefix
isLoggingSuppressed
public static boolean isLoggingSuppressed(@Nullable Map<String,Object> hints)
Whether to suppress logging based on the hintSUPPRESS_LOGGING_HINT
.- 参数:
hints
- the hints map- 返回:
- whether logging of data is allowed
merge
public static Map<String,Object> merge(Map<String,Object> hints1, Map<String,Object> hints2)
Merge two maps of hints, creating and copying into a new map if both have values, or returning the non-empty map, or an empty map if both are empty.- 参数:
hints1
- 1st map of hintshints2
- 2nd map of hints- 返回:
- a single map with hints from both
merge
public static Map<String,Object> merge(Map<String,Object> hints, String hintName, Object hintValue)
Merge a single hint into a map of hints, possibly creating and copying all hints into a new map, or otherwise if the map of hints is empty, creating a new single entry map.- 参数:
hints
- a map of hints to be mergehintName
- the hint name to mergehintValue
- the hint value to merge- 返回:
- a single map with all hints