Showing posts with label Apache Commons. Show all posts
Showing posts with label Apache Commons. Show all posts

Thursday, August 14, 2014

How to quickily clone an object in java

To quickly clone an java object, including all the children and relationships.
may consider to use SerializationUtils in Apache Commons Lang.

it's just easy with  1 line of code

MyObject newObject = (MyObject) SerializationUtils.clone(objectToClone);


Done!!

Tuesday, August 20, 2013

How to generate Alphanumeric with Apache commons-id

Instead of numeric sequence number, alphanumeric sequence may more occurrences.
Because a single number has only 10 occurrences (0-9), but a single alphanumeric sequence has 36 occurrences (0-9 + a-z).

It is a tedious work if we write our own codes to generate the alphanumeric sequence.
There is an easy way with Apache commons id.

Apache commons id is not release yet, but we can download it here.
Although using a pre-release library is not a good practice, but use only 1 class/function should be not a big issue.

LinkWithin

Related Posts Plugin for WordPress, Blogger...