public abstract class Hints extends Object
ResourceRegionEncoder.BOUNDARY_STRING_HINT
Modifier and Type | Field and Description |
---|---|
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.
|
Constructor and Description |
---|
Hints() |
Modifier and Type | Method and Description |
---|---|
static Map<String,Object> |
from(String hintName,
Object value)
Create a map wit a single hint via
Collections.singletonMap(K, V) . |
static String |
getLogPrefix(Map<String,Object> hints)
Obtain the hint
LOG_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 hint
SUPPRESS_LOGGING_HINT . |
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> |
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> |
none()
Return an empty map of hints via
Collections.emptyMap() . |
static void |
touchDataBuffer(DataBuffer buffer,
Map<String,Object> hints,
Log logger)
If the hints contain a
LOG_PREFIX_HINT and the given logger has
DEBUG level enabled, apply the log prefix as a hint to the given buffer
via DataBufferUtils.touch(DataBuffer, Object) . |
public static final String LOG_PREFIX_HINT
public static final String SUPPRESS_LOGGING_HINT
public static Map<String,Object> from(String hintName, Object value)
Collections.singletonMap(K, V)
.hintName
- the hint namevalue
- the hint valuepublic static Map<String,Object> none()
Collections.emptyMap()
.public static <T> T getRequiredHint(@Nullable Map<String,Object> hints, String hintName)
T
- the hint type to cast tohints
- the hints maphintName
- the required hint nameIllegalArgumentException
- if the hint is not foundpublic static String getLogPrefix(@Nullable Map<String,Object> hints)
LOG_PREFIX_HINT
, if present, or an empty String.hints
- the hints passed to the encode methodpublic static boolean isLoggingSuppressed(@Nullable Map<String,Object> hints)
SUPPRESS_LOGGING_HINT
.hints
- the hints mappublic static Map<String,Object> merge(Map<String,Object> hints1, Map<String,Object> hints2)
hints1
- 1st map of hintshints2
- 2nd map of hintspublic static Map<String,Object> merge(Map<String,Object> hints, String hintName, Object hintValue)
hints
- a map of hints to be mergehintName
- the hint name to mergehintValue
- the hint value to mergepublic static void touchDataBuffer(DataBuffer buffer, @Nullable Map<String,Object> hints, Log logger)
LOG_PREFIX_HINT
and the given logger has
DEBUG level enabled, apply the log prefix as a hint to the given buffer
via DataBufferUtils.touch(DataBuffer, Object)
.buffer
- the buffer to touchhints
- the hints map to check for a log prefixlogger
- the logger whose level to check