Package com.deere.isg.worktracker.spring
Class PathMetadataCleanser
- java.lang.Object
-
- com.deere.isg.worktracker.spring.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 usingWork#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 Summary
Constructors Constructor Description PathMetadataCleanser()PathMetadataCleanser(Map<String,String> standardMap)standardMap keys and values will be converted from CamelCase to snake_case
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddBanned(String key, String value)Converts CamelCase to snake_case when adding to bannedMapvoidaddStandard(String key, String value)Converts CamelCase to snake_case when adding to standardMapStringcleanse(String key, String value, String requestUri)voidsetTransformFunction(java.util.function.Function<String,String> function)Sets the function to transform the key which is executed whencleanse(String, String, String)is called
-
-
-
Method Detail
-
cleanse
public String cleanse(String key, String value, String requestUri)
- Specified by:
cleansein interfaceKeyCleanser
-
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 replacevalue- 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 restrictvalue- 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 whencleanse(String, String, String)is called- Parameters:
function- The transformation function to convert the key
-
-