In this post under Mockito, I will show with example how to stub a non-static void method to throw an exception. For our example I will use the below classes. PersonDAO package package10; import java.sql.SQLException; public class PersonDAO { public void save() throws SQLException { System.out.println("Data is saved"); } } PersonManager package package10; import java.sql.SQLException;…… Continue reading Stubbing a non-static void method to throw an exception
Full masking of email address with configured delimiter
In this post under DataMask, I will show with example how to do full masking of email address excluding delimiter. So if the text is “john.doe@gmail.com”, the output should be “****.***@gmail.com”. The delimiter “.” is not masked, it 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…… Continue reading Full masking of email address with configured delimiter
Accessing main class members using instance main method
In this post under Java Language, I will show with example how to access member variables and methods when using instance main method. But before showing the new approach lets recap the old approach. This will help in comparing old and new approach. Below is the example showing the old approach Old Approach package core.language;…… Continue reading Accessing main class members using instance main method
Stubbing a non-static void method to do nothing
In this post under Mockito, I will show with example how to stub a non-static void method to do nothing. For our example, I will use the below class MyCustomLogger package package9;public class MyCustomLogger { public void info() { System.out.println("adding a and b"); } } Calculator package package9;public class Calculator { private MyCustomLogger myCustomLogger; public…… Continue reading Stubbing a non-static void method to do nothing
Middle masking of email address without configuring delimiter
In this post under DataMask, I will show with example how to do middle masking of email address including delimiter. So if the text is “john.doe@gmail.com”, the output should be “jo****oe@gmail.com”. The delimiter “.” is also masked. 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; import io.github.freewarelabs.datamask.core.MaskType;…… Continue reading Middle masking of email address without configuring delimiter
New changes to age old main method
In this post under Java, Language, I will introduce you to changes done to our age old main method as part of Java 25. Pre Java 25, if we have to write our main method, we used to mark it public make the return value of the method “void” mark it static provide String array…… Continue reading New changes to age old main method
Side masking of email address without configuring delimiter
In this post under DataMask, I will show with example how to do side masking of email address including masking of delimiter. So if the text is “john.doe@gmail.com”, the output should be “**hn****@gmail.com” 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; import io.github.freewarelabs.datamask.core.MaskType; import io.github.freewarelabs.datamask.core.exception.DataMaskException; public class…… Continue reading Side masking of email address without configuring delimiter
Instance Main and Non-Instance Main method in one class example
In this post under Java language, I will show with example how Java runs a program which has two main methods. Here two main methods means one traditional public static void main method as shown below public static void main(String[] args) { } and another being the new main method as shown below void main()…… Continue reading Instance Main and Non-Instance Main method in one class example
Instance Main method example
In this post under Java language, I will introduce you to new feature added to Java called “Instance Main Method”. This feature was added in Java version 25. Pre Java 25, if we have to write class with “main” method, we used to mark it as public and static as shown below. You also need…… Continue reading Instance Main method example
Conditional caching using SpEL
In this post under Spring Caching, I will show with example how to enable conditional caching using SpEL. In previous posts I showed you how to use “@Cacheable” annotation. In that annotation itself there is an attribute that we can use to enable conditional caching. That attribute name is “condition” and it takes as SpEL…… Continue reading Conditional caching using SpEL