“Every problem becomes childish when once it is explained to you”

Monday, June 27, 2011

Common uses of Apache Commons

Apache Commons is a collection of reusable java components which extends the official java functionality. These libraries helped me to reduce my code complexity.
Here I am listing down some handy methods that I used in my projects.

1.StringUtils
a)IsEmpty/IsBlank - checks if a String contains text
b)Trim/Strip - removes leading and trailing whitespace
c)Split/Join - splits a String into an array of substrings and vice versa
d)IsAlpha/IsNumeric/IsWhitespace/IsAsciiPrintable - checks the characters in a String


2.BeanUtils
a)copyProperties(Object dest, Object orig) Copy property values from the origin bean to the destination bean for all cases where the property names are the same.
b)describe(Object bean) Return the entire set of properties for which the specified bean provides a read method.
c)populate(Object bean, Map properties) Populate the JavaBeans properties of the specified bean, based on the specified name/value pairs.


3.CollectionUtils
a)intersection(java.util.Collection a, java.util.Collection b) Returns a Collection containing the intersection of the given Collections.
b)isEmpty(java.util.Collection coll) Null-safe check if the specified collection is empty.
c)subtract(java.util.Collection a, java.util.Collection b) Returns a new Collection containing a - b.

8 comments:

  1. Apache commons is very useful. The only problems happen when you have two modules (say hibernate and a graphing library) that both use different versions of the same commons lib. At that point you pray that you can drop the older version and that the new version is backwards compatible enough to be used.

    ReplyDelete
  2. I would add:
    Validate.isTrue()
    Validate.notNull()

    ReplyDelete
  3. Apache commons are great. I like this post for its simplicity but it could have been more detailed.

    Javin
    Difference among String vs StringBuffer vs StringBuilder

    ReplyDelete
  4. I really appreciate information shared above. It’s of great help. If someone want to learn Online (Virtual) instructor lead live training in Apache Spark MLIB, kindly contact us http://www.maxmunus.com/contact
    MaxMunus Offer World Class Virtual Instructor led training on Apache Spark MLIB. We have industry expert trainer. We provide Training Material and Software Support. MaxMunus has successfully conducted 100000+ trainings in India, USA, UK, Australlia, Switzerland, Qatar, Saudi Arabia, Bangladesh, Bahrain and UAE etc.
    For Demo Contact us:
    Name : Arunkumar U
    Email : arun@maxmunus.com
    Skype id: training_maxmunus
    Contact No.-+91-9738507310
    Company Website –http://www.maxmunus.com


    ReplyDelete
  5. I really appreciate information shared above. It’s of great help. If someone want to learn Online (Virtual) instructor lead live training in Apache Spark MLIB, kindly contact us http://www.maxmunus.com/contact
    MaxMunus Offer World Class Virtual Instructor led training on Apache Spark MLIB. We have industry expert trainer. We provide Training Material and Software Support. MaxMunus has successfully conducted 100000+ trainings in India, USA, UK, Australlia, Switzerland, Qatar, Saudi Arabia, Bangladesh, Bahrain and UAE etc.
    For Demo Contact us:
    Name : Arunkumar U
    Email : arun@maxmunus.com
    Skype id: training_maxmunus
    Contact No.-+91-9738507310
    Company Website –http://www.maxmunus.com


    ReplyDelete
  6. I really appreciate information shared above. It’s of great help. If someone want to learn Online (Virtual) instructor lead live training in Apache Spark TECHNOLOGY , kindly contact us http://www.maxmunus.com/contact
    MaxMunus Offer World Class Virtual Instructor-led training on TECHNOLOGY. We have industry expert trainer. We provide Training Material and Software Support. MaxMunus has successfully conducted 100000+ pieces of training in India, USA, UK, Australia, Switzerland, Qatar, Saudi Arabia, Bangladesh, Bahrain and UAE etc.
    For Demo Contact us.
    Pratik Shekhar
    MaxMunus
    E-mail: pratik@maxmunus.com
    Ph:(0) +91 9066268701
    http://www.maxmunus.com/

    ReplyDelete
  7. I really appreciate information shared above. It’s of great help. If someone want to learn Online (Virtual) instructor lead live training in Apache Spark TECHNOLOGY , kindly contact us http://www.maxmunus.com/contact
    MaxMunus Offer World Class Virtual Instructor-led training on TECHNOLOGY. We have industry expert trainer. We provide Training Material and Software Support. MaxMunus has successfully conducted 100000+ pieces of training in India, USA, UK, Australia, Switzerland, Qatar, Saudi Arabia, Bangladesh, Bahrain and UAE etc.
    For Demo Contact us.
    Pratik Shekhar
    MaxMunus
    E-mail: pratik@maxmunus.com
    Ph:(0) +91 9066268701
    http://www.maxmunus.com/

    ReplyDelete