Package org.springframework.core.codec
Class Hints
java.lang.Object
org.springframework.core.codec.Hints
Constants and convenience methods for working with hints.
- Since:
- 5.1
- Author:
- Rossen Stoyanchev
- See Also:
- 
Field SummaryFieldsModifier and TypeFieldDescriptionstatic final StringName of hint exposing a prefix to use for correlating log messages.static final StringName of boolean hint whether to avoid logging data either because it's potentially sensitive, or because it has been logged by a composite encoder, for example, for multipart requests.
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionCreate a map wit a single hint viaCollections.singletonMap(K, V).static StringgetLogPrefix(@Nullable Map<String, Object> hints) Obtain the hintLOG_PREFIX_HINT, if present, or an empty String.static <T> TObtain the value for a required hint.static booleanisLoggingSuppressed(@Nullable Map<String, Object> hints) Whether to suppress logging based on the hintSUPPRESS_LOGGING_HINT.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.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.none()Return an empty map of hints viaCollections.emptyMap().static voidtouchDataBuffer(DataBuffer buffer, @Nullable Map<String, Object> hints, org.apache.commons.logging.Log logger) If the hints contain aLOG_PREFIX_HINTand the given logger has DEBUG level enabled, apply the log prefix as a hint to the given buffer viaDataBufferUtils.touch(DataBuffer, Object).
- 
Field Details- 
LOG_PREFIX_HINTName of hint exposing a prefix to use for correlating log messages.
- 
SUPPRESS_LOGGING_HINTName of boolean hint whether to avoid logging data either because it's potentially sensitive, or because it has been logged by a composite encoder, for example, for multipart requests.
 
- 
- 
Constructor Details- 
Hintspublic Hints()
 
- 
- 
Method Details- 
fromCreate a map wit a single hint viaCollections.singletonMap(K, V).- Parameters:
- hintName- the hint name
- value- the hint value
- Returns:
- the created map
 
- 
noneReturn an empty map of hints viaCollections.emptyMap().- Returns:
- the empty map
 
- 
getRequiredHintObtain the value for a required hint.- Type Parameters:
- T- the hint type to cast to
- Parameters:
- hints- the hints map
- hintName- the required hint name
- Returns:
- the hint value
- Throws:
- IllegalArgumentException- if the hint is not found
 
- 
getLogPrefixObtain the hintLOG_PREFIX_HINT, if present, or an empty String.- Parameters:
- hints- the hints passed to the encode method
- Returns:
- the log prefix
 
- 
isLoggingSuppressedWhether to suppress logging based on the hintSUPPRESS_LOGGING_HINT.- Parameters:
- hints- the hints map
- Returns:
- whether logging of data is allowed
 
- 
mergepublic static Map<String,Object> merge(@Nullable Map<String, Object> hints1, @Nullable 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.- Parameters:
- hints1- 1st map of hints
- hints2- 2nd map of hints
- Returns:
- a single map with hints from both
 
- 
mergepublic static Map<String,Object> merge(@Nullable 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.- Parameters:
- hints- a map of hints to be merged
- hintName- the hint name to merge
- hintValue- the hint value to merge
- Returns:
- a single map with all hints
 
- 
touchDataBufferpublic static void touchDataBuffer(DataBuffer buffer, @Nullable Map<String, Object> hints, org.apache.commons.logging.Log logger) If the hints contain aLOG_PREFIX_HINTand the given logger has DEBUG level enabled, apply the log prefix as a hint to the given buffer viaDataBufferUtils.touch(DataBuffer, Object).- Parameters:
- buffer- the buffer to touch
- hints- the hints map to check for a log prefix
- logger- the logger whose level to check
- Since:
- 5.3.2
 
 
-