Class PathMetadataCleanser

  • All Implemented Interfaces:
    KeyCleanser

    public class PathMetadataCleanser
    extends Object
    implements KeyCleanser
    By default, when adding a standardMap to this cleanser, it will convert all CamelCase keys and values to snake_case. This is to make sure that the key is added properly using Work#addToMDC(key, value)

    STANDARD is for changing non-standard keys to standard keys Example: test_user_id becomes user_id another_user_id becomes user_id

    BANNED is for blacklisting keys Example: id becomes unknown_id

    Setup

    
     @Bean
     public KeyCleanser keyCleanser() {
         return new PathMetadataCleanser(STANDARD_MAP);
     }
     
    • Constructor Detail

      • PathMetadataCleanser

        public PathMetadataCleanser()
      • PathMetadataCleanser

        public PathMetadataCleanser​(Map<String,​String> standardMap)
        standardMap keys and values will be converted from CamelCase to snake_case
        Parameters:
        standardMap - keys that you want to replace for standardization
    • Method Detail

      • addStandard

        public void addStandard​(String key,
                                String value)
        Converts CamelCase to snake_case when adding to standardMap
        Parameters:
        key - the key that you want to replace
        value - the key that you are replacing with
      • addBanned

        public void addBanned​(String key,
                              String value)
        Converts CamelCase to snake_case when adding to bannedMap
        Parameters:
        key - the key that you want to restrict
        value - the key that you are replacing with
      • setTransformFunction

        public void setTransformFunction​(java.util.function.Function<String,​String> function)
        Sets the function to transform the key which is executed when cleanse(String, String, String) is called
        Parameters:
        function - The transformation function to convert the key