camel-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Claus Ibsen" <claus.ib...@gmail.com>
Subject [HEADS-UP] - Minor ObjectHelper refact to align null and empty check
Date Wed, 10 Dec 2008 11:48:19 GMT
Hi

Ticket: CAMEL-1155

#1
I have aligned the various isNotNullOrNonEmpty / isBlank etc. methods
in ObjectHelper into two combined methods.

These old methods have been removed in Camel 2.0
- isNotNullAndNonEmpty
- isNullOrBlank

And replaced with (see below)

#2
I have also refined the notNull methods to use these new test methods
so we test for both null and if its a String type if the string is
empty as well.

I have added a variation of the notNull tester with a 3rd parameter =
on. This parameter is appended to the message being thrown. This helps
end users to identify where the problem is.
In the various model types we can use this 3 parameter passing in
*this*. So the error reported will output the toString of the node, so
it's like

For instance this route will use a bean with the id=hello
from("direct:in").processRef("hello");

But if the bean is not in the registry you now get this error message:
     registry entry called hello must be specified on: process[ref: hello]
Instead of just:
     registry entry called hello must be specified



New methods to use
===============

    public static void notNull(Object value, String name, Object on) {


    /**
     * Tests whether the value is <tt>null</tt> or an empty string.
     *
     * @param value the value, if its a String it will be tested for
text length as well
     * @return true if empty
     */
    public static boolean isEmpty(Object value) {

    /**
     * Tests whether the value is <b>not</b> <tt>null</tt> or an empty
string.
     *
     * @param value the value, if its a String it will be tested for
text length as well
     * @return true if <b>not</b> empty
     */
    public static boolean isNotEmpty(Object value) {





/Claus Ibsen
Apache Camel Committer
Blog: http://davsclaus.blogspot.com/

Mime
View raw message