Posts

Showing posts from July, 2018

Java | Builder Design Pattern

Java POJO classes can be created using different design patterns. Below is example how Builder pattern works. Normally, Simple java POJO class setter-call has void return type. Builder pattern replace void return type and returns current object of class(ie. return this). Builder pattern can be used to replace parameterised constructor. Also when we create object the code is more readable. Example :

Spring | Autowiring Qualifier

Spring provides @Qualifier annotation to refer correct bean while doing autowiring. Suppose we have interface IService which has two concrete implementation. When we try to Autowire IService object in any other class it will throw exception as there are two beans. Spring Qualifier is used in such situation to place object of correct implementation class to autowired object.   Now, above iservice object will hold object of IServiceImplTwo class.