A good hash function tends to produce unequal hash codes for unequal objects. Ideally, a hash function should distribute any reasonable collection of unequal instances uniformly across all possible hash values. Achieving this would be ideal, but can be complex. Luckily the following rules made this easy:
1. Store some constant non zero value, say, 17, in an int variable called result.
2. For each...
A Technology Blog About Code Development, Architecture, Operating System, Hardware, Tips and Tutorials for Developers.
Saturday, October 22, 2016
Wednesday, October 19, 2016
ReflectionUtils.doWithFields()
Spring has a nice Utility class ReflectionUtils that does just that: it defines a method to loop over all fields of all super classes with a callback: ReflectionUtils.doWithFields()
Documentation:
Invoke the given callback on all fields in the target class, going up the class hierarchy to get all declared fields.
Parameters:
- clazz - the target class to analyze
- fc - the callback to invoke...
Wednesday, October 5, 2016
Custom Maven Plugin
When you write a custom plugin, you are going to be writing a series of Mojos (goals). Every Mojo is a single Java class which contains a series of annotations that tell Maven how to generate the Plugin descriptor. Before you can start writing Mojo classes, you will need to create Maven project with the appropriate packaging and POM.
To create a plugin project, you should use the Maven Archetype...