THIS IS A TEST INSTANCE. ALL YOUR CHANGES WILL BE LOST!!!!
...
Proposed Changes
Add 'replacement' field param to config definition:
Code Block | ||||
---|---|---|---|---|
| ||||
private static final String REPLACEMENT_CONFIG = "replacement"; public static final ConfigDef CONFIG_DEF = new ConfigDef() .define(FIELDS_CONFIG, ConfigDef.Type.LIST, ConfigDef.NO_DEFAULT_VALUE, new NonEmptyListValidator(), ConfigDef.Importance.HIGH, "Names of fields to mask.") .define(REPLACEMENT_CONFIG, ConfigDef.Type.STRING, null, new ConfigDef.NonEmptyString(), ConfigDef.Importance.LOW, "Custom value replacement, that will be applied to all" + " 'fields' values (numeric or non-empty string values only)."); |
...
Define mapping functions for custom replacement fieldvalue:
Code Block | ||||
---|---|---|---|---|
| ||||
private static final Map<Class<?>, Function<String, ?>> REPLACEMENT_MAPPING_FUNC = new HashMap<>(); static { REPLACEMENT_MAPPING_FUNC.put(Byte.class, v -> Values.convertToByte(null, v)); REPLACEMENT_MAPPING_FUNC.put(Short.class, v -> Values.convertToShort(null, v)); REPLACEMENT_MAPPING_FUNC.put(Integer.class, v -> Values.convertToInteger(null, v)); REPLACEMENT_MAPPING_FUNC.put(Long.class, v -> Values.convertToLong(null, v)); REPLACEMENT_MAPPING_FUNC.put(Float.class, v -> Values.convertToFloat(null, v)); REPLACEMENT_MAPPING_FUNC.put(Double.class, v -> Values.convertToDouble(null, v)); REPLACEMENT_MAPPING_FUNC.put(String.class, Function.identity()); REPLACEMENT_MAPPING_FUNC.put(BigDecimal.class, BigDecimal::new); REPLACEMENT_MAPPING_FUNC.put(BigInteger.class, BigInteger::new); } |
...