Generating Custom application events

In this post under Spring Core, I will show with example how to create custom application events. For our example, I created a custom event that the application will generate as shown below CustomEvent package package32; import org.springframework.context.ApplicationEvent; public class CustomEvent extends ApplicationEvent { public CustomEvent(Object source) { super(source); } } In the above code,…… Continue reading Generating Custom application events

IllegalCharacterRule example

In this post under Passay, I will explain with example the purpose and how to use “IllegalCharacterRule” class. In the previous, I explained the purpose of “AllowedCharacterRule” class. The class “IllegalCharacterRule” is the opposite of “AllowedCharacterRule”. In “AllowedCharacterRule” we create an array of characters that should be allowed in the password text. In other words…… Continue reading IllegalCharacterRule example

Listening to ApplicationContext events

In this post under Spring Core, I will explain with example how to listen to ApplicationContext events. The Spring framework when creates/stops/refresh an ApplicationContext, it generates certain events and we as a developer can listen to those events and add our custom logic so that it can be executed. For our example, I will create…… Continue reading Listening to ApplicationContext events

Using filters to customize @ComponentScan annotation

In one of my previous posts under Spring Core, I explained the purpose of “@ComponentScan” annotation with example. For recap, “@ComponentScan” annotation when applied at the class level with an package name as an argument tells Spring framework to scan for class files annotated with “@Component” annotationunder the specified package folder. It scans the subfolders…… Continue reading Using filters to customize @ComponentScan annotation

CollectionUtils removeAll method

In this post under Apache Collections, I will explain with example the purpose of “CollectionUtils” class “removeAll” method. This method takes two collections i.e, “collection1” and “collection2” as an arguments. This method searches for elements in “collection2” in “collection1”. If the element is found in “collection1”, it is removed. Basically, it returns a collection say…… Continue reading CollectionUtils removeAll method

Permutations of collection elements

In this post under Apache collections, I will explain with example, how to generate a collection of possible permutations of a particular collection elements. If we have collection of elements, we can generate a list of different permutations containing the same elements. The Apache Collections tool, has a “permutations” method in “CollectionUtils” class. This method…… Continue reading Permutations of collection elements

Comparing two collections for equality

In this post under Apache Collections, I will show with example how to compare two collections for equality. We consider two collections are equal if they have same elements repeated same number of times. The Apache Collections tool has “isEqualCollection” method on “CollectionUtils” class which we can use to compare two collections for equality. Below…… Continue reading Comparing two collections for equality

HaveIBeenPwnedRule setAllowOnException method example

In previous post under Passay, I showed with example how to use “HaveIBeenPwnedRule” rule. Just for recap, there is a website “haveibeenpwned.com” that contains a list of real world passwords that were previously used and exposed as part of data breaches. This rule will check user enteredpassword against that database. If password is already present,…… Continue reading HaveIBeenPwnedRule setAllowOnException method example