Side masking of email address with configured delimiter

In this post under DataMask, I will show with example how to do side masking of email address excluding masking of delimiter. So if the email address is “john.doe@gmail.com”, the output should be “**h*.***@gmail.com”. The delimiter “.” is excluded. Below is the complete main class Main class package core; import io.github.freewarelabs.datamask.core.DataFormatType; import io.github.freewarelabs.datamask.core.DataMaskManager; import io.github.freewarelabs.datamask.core.MaskInformationDTO;…… Continue reading Side masking of email address with configured delimiter

Stubbing a non-void non-static method to throw an exception

In this post under Mockito, I will show with example how to stub mock object’s non-void non-static method to throw an exception. In previous posts under Mockito, I have shown you how to stub mock object’s non-static void method to throw an exception by using Mockito’s “doThrow” method and passing the exception class object as…… Continue reading Stubbing a non-void non-static method to throw an exception

Middle masking of delimited text without configuring delimiter

In this post under DataMask, I will show with example how to do middle masking of delimited text including masking of delimiter. So if the text is “1111-2222-3333-4444”, the output should be “111**********3-4444”. The delimiter “-” is also masked, it is not excluded. Below is the complete main class Main class package core; import io.github.freewarelabs.datamask.core.DataFormatType;…… Continue reading Middle masking of delimited text without configuring delimiter

Creating custom cache key using KeyGenerator interface

In all my previous posts under Spring Caching, I have used Java primitive types and String as cache key. In this post under Spring Caching, I will show with example how to create custom cache key. To create a custom cache key we need to implement Spring interface “KeyGenerator” and provide the logic that creates…… Continue reading Creating custom cache key using KeyGenerator interface

var variable value can change but not datatype

In this post under Java language, I will introduce you to one of the restrictions that apply to var variable. In the previous post under Java language, I introduce you guys to var variable (local variable type inference variable) and also covered some restrictions to remember when declaring var variable. But didn’t covered this restriction…… Continue reading var variable value can change but not datatype

Local Variable Type Inference (var) example

In this post under Java language, I will introduce you to Local Variable Type Inference (also called var variable) added in Java 10. Before java 10, any variable declared should be accompained with the data type as shown below int sum; float salary; String name; As shown in the above code, the “int” is the…… Continue reading Local Variable Type Inference (var) example

Stubbing a non-static non-void method to return multiple values for consecutive calls

In this post under Mockito, I will show with example how to stub a mock object’s non-static non-void method to return different values when called consecutively. For our example, we will use the below class MyRandom package package11; import java.util.Random; public class MyRandom { private Random random; public MyRandom() { random = new Random(); }…… Continue reading Stubbing a non-static non-void method to return multiple values for consecutive calls

Accessing return value of method execution while vetoing caching using SpEL

In the previous post under Spring Caching, I have shown how to veto caching but didn’t mention that we can also access the method return value or result in making that decision. In this post under Spring Caching, I will show how to do that. For our example, I will use the below class Calculator…… Continue reading Accessing return value of method execution while vetoing caching using SpEL

Side masking of delimited text without configuring delimiter

In this post under DataMask, I will show with example how to do side masking of delimited text including masking of delimiter. So if the text is “1111-2222-3333-4444”, the output should be “***1-2222-333******”. The delimiter “.” is also masked, it is not excluded. Below is the complete main class Main class package core; import io.github.freewarelabs.datamask.core.DataFormatType;…… Continue reading Side masking of delimited text without configuring delimiter