In this post under Java, we will explain with an example the andThen method under BiFunction functional interface. BiFunction’s andThen method is used to chain a BiFunction interface implementation with one or more Function interface implementations. Lets consider an example. I have a list of employess with their salary and percent of bonus to apply…… Continue reading BiFunction’s andThen Example
javax.mail.Authenticator Example
javax.mail.Authenticator Example In this post under Java Mail, I will explain the use of Authenticator abstract class with an example. Note: For this example and other examples in future we need to have1) Gmail account2) GMail SMTP server address3) Stop the antivirus software running on your local.4) Create an application password. The steps are mentioned…… Continue reading javax.mail.Authenticator Example
ConnectionListener Example
In this post under Java Mail, I will explain the use of ConnectionListener interface with an example. Note: For this example and other examples in future we need to have1) Gmail account2) GMail SMTP server address3) Stop the antivirus software running on your local.4) Create an application password. The steps are mentioned in the url…… Continue reading ConnectionListener Example
Chaining multiple ChunkListeners
In this post under Spring Batch, I will explain how to chain multiple ChunkListener together. For this example I will create two custom ChunkListener interface implementations named ‘CustomChunkListener1’ and ‘CustomChunkListener2’ as shown below CustomChunkListener1 package package35; import org.springframework.batch.core.ChunkListener; import org.springframework.batch.core.scope.context.ChunkContext; public class CustomChunkListener1 implements ChunkListener { @Override public void afterChunk(ChunkContext chunkContext) { System.out.println(“ChunkListener1 processing ended…… Continue reading Chaining multiple ChunkListeners
BiConsumer Example
In this post, I will show how to use BiConsumer functional interface with an example. BiConsumer functional interface is similar to Consumer functional interface. It takes an input, processes it and doesn’t return anything. The difference lies in the number of inputs taken by the BiConsumer functional interface. Consumer functional interface takes one input whereas…… Continue reading BiConsumer Example
TransportListener Example
In this post under Java Mail, I will explain with example the purpose and how to use TransportListener interface. Note: For this example and other examples in future we need to have1) Gmail account2) GMail SMTP server address3) Stop the antivirus software running on your local.4) Create an application password. The steps are mentioned in…… Continue reading TransportListener Example
Private Interface Methods
From Java 9 onwards, we can declare private methods in interface. In this post I will show with an example of how to do it. Private methods in interface are useful if you have logic shared by more than one default interface methods. We can put the shared logic in the private method. Below is…… Continue reading Private Interface Methods
BiFunction Example
In this post, I will show how to use BiFunction functional interface with an example. BiFunction functional interface is similar to Function functional interface. It takes an input and produces an output. The difference lies in the number of inputs taken by the BiFunction functional interface. Function functional interface takes one input and produced one…… Continue reading BiFunction Example
Chaining multiple ItemProcessorListener
In this post under Spring Batch, I will explain with example how to chain multiple ItemProcessorListeners. For our example we create two ItemProcessorListener as shown below CustomItemProcessListener1 package package34; import org.springframework.batch.core.ItemProcessListener; public class CustomItemProcessListener1 implements ItemProcessListener { @Override public void afterProcess(Employee employee1, Employee employee2) { System.out.println(“CustomItemProcessListener1: Item processing completed”); } @Override public void beforeProcess(Employee employee)…… Continue reading Chaining multiple ItemProcessorListener
Sending Email Using SMTP (Approach 2)
In this post under Java Mail. I will show with an example how to send email using Java Mail api and SMTP protocol. Note: For this example and other examples in future we need to have 1) Gmail account 2) GMail SMTP server address 3) Stop the antivirus software running on your local. 4) Create…… Continue reading Sending Email Using SMTP (Approach 2)