-
-
Save monkey-codes/c5cc163b92bca3e96cdbdccff5b83289 to your computer and use it in GitHub Desktop.
PII Masking ToStringBuilder
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class PIIMaskingToStringBuilder(value: Any?, toStringStyle: ToStringStyle = RecursivePIIMaskingToStringStyle) : | |
| ReflectionToStringBuilder(value, toStringStyle) { | |
| override fun getValue(field: Field?): Any? { | |
| return field?.getAnnotation(PII::class.java)?.let { | |
| mask(super.getValue(field)) | |
| } ?: super.getValue(field) | |
| } | |
| companion object { | |
| fun toString(value: Any?): String = PIIMaskingToStringBuilder(value, RecursivePIIMaskingToStringStyle).toString() | |
| fun mask(value: Any?) = | |
| Configuration.dataMaskingFunction.mask(value) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment