What's new in Commons Lang 2.5?Commons Lang 2.5 is out, and the obvious question is: "So what? What's changed?". This article aims to briefly cover the changes and save you from having to dig through each JIRA issue to see what went on in the two years of development between Lang 2.4 and 2.5. Two years?!? Yes, it's true. The reason is that 2.5 represents the backwards compatible changes in the nearly complete Java-5 focused Lang 3.0. DeprecationsThere were no new deprecations in 2.5. The build2.5 was built using Sun's 1.6.0_17 JVM, but targets Java 1.3. New classesA new org.apache.commons.lang.reflect package was added, accumulating common high-level uses of the java.lang.reflect APIs. The classes, hopefully self-evident in nature, were pulled together from the existing BeanUtils and the unreleased Reflect components. The classes are:
You can read more about the classes in their javadoc. New fieldsWith both Java 7 and Windows 7 becoming a reality, SystemUtils was updated to provide boolean fields for both versions. New methodsThere were 66 new methods added to existing Commons Lang classes. The ArrayUtils class received two new types of methods. Firstly, a boolean isNotEmpty(array) set of methods, identifying whether the particular array is null or an empty sized array. This makes it the inverse of the existing isEmpty(array) methods. Secondly, an array nullToEmpty(array) set of methods that converts null or empty arrays to a singleton empty array already available from the ArrayUtils class. Non-null/empty arrays are left untouched. The constructor for the CharRange class is somewhat confusing. It takes a boolean parameter that when set to true means the CharRange is negated. To make code easier to read, the following static helper methods were added:
An iterator() method was also added to provide another way of walking the range. The EqualsBuilder obtained a new reset() method to allow for reuse, while the HashCodeBuilder received a hashCode() method that returns the built hash code instead of the natural hash code of the builder object itself. It doesn't really matter what the builder chooses to use as a hash code and this stops accidental use of the hashCode() instead of toHashCode() method from causing lots of pain. Helper isFalse(), isTrue() and toBoolean() methods were added to MutableBoolean, while the other mutable classes received String argument constructors. Lastly, the DateUtils class received a new ceiling set of methods to truncate upwards, and a parseDateStrictly method to parse a Date with the supplied DateFormat classes leniency set to false. StringUtils methodsAs with 2.4, the StringUtils class has grown and we cover its new methods in its own section.
What's fixed in Lang 2.5?Per the release notes there are 32 bugs fixed in Lang 2.5. Some highlights are:
So long, farewell...Hopefully that was all of interest. Don't forget to download Lang 2.5, or, for the Maven repository users, upgrade your <version> tag to 2.5. Please feel free to raise any questions you might have on the mailing lists, and report bugs or enhancements in the issue tracker. |