org.springframework.core.codec

Class Hints

  • java.lang.Object
    • org.springframework.core.codec.Hints
    • Field Summary

      Fields 
      Modifier and Type Field and Description
      static java.lang.String LOG_PREFIX_HINT
      Name of hint exposing a prefix to use for correlating log messages.
      static java.lang.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 Summary

      Constructors 
      Constructor and Description
      Hints() 
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method and Description
      static java.util.Map<java.lang.String,java.lang.Object> from(java.lang.String hintName, java.lang.Object value)
      Create a map wit a single hint via Collections.singletonMap(K, V).
      static java.lang.String getLogPrefix(java.util.Map<java.lang.String,java.lang.Object> hints)
      Obtain the hint LOG_PREFIX_HINT, if present, or an empty String.
      static <T> T getRequiredHint(java.util.Map<java.lang.String,java.lang.Object> hints, java.lang.String hintName)
      Obtain the value for a required hint.
      static boolean isLoggingSuppressed(java.util.Map<java.lang.String,java.lang.Object> hints)
      Whether to suppress logging based on the hint SUPPRESS_LOGGING_HINT.
      static java.util.Map<java.lang.String,java.lang.Object> merge(java.util.Map<java.lang.String,java.lang.Object> hints1, java.util.Map<java.lang.String,java.lang.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 java.util.Map<java.lang.String,java.lang.Object> merge(java.util.Map<java.lang.String,java.lang.Object> hints, java.lang.String hintName, java.lang.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 java.util.Map<java.lang.String,java.lang.Object> none()
      Return an empty map of hints via Collections.emptyMap().
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • LOG_PREFIX_HINT

        public static final java.lang.String LOG_PREFIX_HINT
        Name of hint exposing a prefix to use for correlating log messages.
      • SUPPRESS_LOGGING_HINT

        public static final java.lang.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.
    • Constructor Detail

      • Hints

        public Hints()
    • Method Detail

      • from

        public static java.util.Map<java.lang.String,java.lang.Object> from(java.lang.String hintName,
                                                                            java.lang.Object value)
        Create a map wit a single hint via Collections.singletonMap(K, V).
        Parameters:
        hintName - the hint name
        value - the hint value
        Returns:
        the created map
      • none

        public static java.util.Map<java.lang.String,java.lang.Object> none()
        Return an empty map of hints via Collections.emptyMap().
        Returns:
        the empty map
      • getRequiredHint

        public static <T> T getRequiredHint(@Nullable
                                            java.util.Map<java.lang.String,java.lang.Object> hints,
                                            java.lang.String hintName)
        Obtain 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:
        java.lang.IllegalArgumentException - if the hint is not found
      • getLogPrefix

        public static java.lang.String getLogPrefix(@Nullable
                                                    java.util.Map<java.lang.String,java.lang.Object> hints)
        Obtain the hint LOG_PREFIX_HINT, if present, or an empty String.
        Parameters:
        hints - the hints passed to the encode method
        Returns:
        the log prefix
      • isLoggingSuppressed

        public static boolean isLoggingSuppressed(@Nullable
                                                  java.util.Map<java.lang.String,java.lang.Object> hints)
        Whether to suppress logging based on the hint SUPPRESS_LOGGING_HINT.
        Parameters:
        hints - the hints map
        Returns:
        whether logging of data is allowed
      • merge

        public static java.util.Map<java.lang.String,java.lang.Object> merge(java.util.Map<java.lang.String,java.lang.Object> hints1,
                                                                             java.util.Map<java.lang.String,java.lang.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
      • merge

        public static java.util.Map<java.lang.String,java.lang.Object> merge(java.util.Map<java.lang.String,java.lang.Object> hints,
                                                                             java.lang.String hintName,
                                                                             java.lang.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 merge
        hintName - the hint name to merge
        hintValue - the hint value to merge
        Returns:
        a single map with all hints