Java Generics – conditionally instantiate a class
From Class to list of Enums So if I want to instantiate a class via some condition, I can do the following but still how do I know what type to use? https://github.com/dodozhang21/JavaGenerics
From Class to list of Enums So if I want to instantiate a class via some condition, I can do the following but still how do I know what type to use? https://github.com/dodozhang21/JavaGenerics
At work, I’ve implemented a queue monitor batch application. Due to business rule changes, it now needs to monitor two queues. Instead of creating another batch application, I really wanted to stick with the same application but just create two threads, each monitoring its own queue. However, the twist I need is to have the… Continue reading Java concurrency – Multiple queue monitors
After the cijug presentation on Grails, I’ve decided I will not use it. I know Grails is hot and cool but I don’t like it. It’s probably just a personal preference. Why don’t I want to use Grails It’s built on spring and hibernate, so why not just use them directly? It’s just adding another… Continue reading Grails: I will not use you
A business rule at work requires some flexible configurations. I attempted to fulfill the need by create different spring batch steps/tasklets to execute each requirement based on a property value. For example, step 1 will need to execute methodOne on the class Repository with the appropriate parameters. The method signature & parameters are determined by… Continue reading Dynamically invoke methods using spring config
I was looking for a complete example of how to dynamically generate the page numbers when you create the pdf using iText and I couldn’t find one. This is based on the example in the iText in Action book but I added my “refactoring” if you will. I hope this helps someone. If not, it… Continue reading itext page number (page x of y)
At work I had to create some test data for a junit test. The function I’m testing expects a super abstract class to be passed in and I need to test the same function for bunch of child classes. I wish I could just pass in the parent class but since it’s abstract I cannot… Continue reading Java instaniate an abstract class… sort of…
Not really a new trick but I had to look for the syntax today to use reflection to set a private property on an object to use it in a junit test.
While reviewing the findbugs report (WMI_WRONG_MAP_ITERATOR) for a new project at work, I learned a better way to traverse a map in Java. In fact, since the first day I started coding in Java, I never thought twice about how to traverse a map. You always traverse the keys and use the key to get… Continue reading Java: BETTER way to traverse a map
Something I always forget, a shortcut array syntax for Java:
I don’t know if this is a new feature in Java 5 that I did not know before or I just did not know this is possible in Java. But I learned today that you can do static declaration of collection types as below: