Empty or Blank - the choice is here now

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Empty or Blank - the choice is here now

Claus Ibsen-2
Hi

Now that we have the chance to change the API for Camel 2.0 I have a
few very minor issues as well.

We have methods on ObjectHelper for assertions of null and if strings
is provided or not.
We currently have a mix of String assertions methods that use *empty*
or *blank* to indicate if a string is provided or not.

I think we should align and only use either *blank* or *empty* for
"empty" strings

Personally I am used to empty

ObjectHelper.isNotNullOrNonEmpty(String s);
And this cryptic name could be consider renamed to

ObjectHelper.isNotEmpty(String s);
ObjectHelper.isEmpty(String s);

We could have just object parameters and if the type is a string we
can do the cast to string and do the trim.length > 0 test.
So we only have these two methods to remember
ObjectHelper.isNotEmpty(Object s);
ObjectHelper.isEmpty(Object s);

They will test for null and trim strings if its a string type.

Am I making myself clear?


/Claus Ibsen
Apache Camel Committer
Blog: http://davsclaus.blogspot.com/
Reply | Threaded
Open this post in threaded view
|

Re: Empty or Blank - the choice is here now

jstrachan
Sounds good. By 'empty' we mean either null or zero length right?


On 08/12/2008, Claus Ibsen <[hidden email]> wrote:

> Hi
>
> Now that we have the chance to change the API for Camel 2.0 I have a
> few very minor issues as well.
>
> We have methods on ObjectHelper for assertions of null and if strings
> is provided or not.
> We currently have a mix of String assertions methods that use *empty*
> or *blank* to indicate if a string is provided or not.
>
> I think we should align and only use either *blank* or *empty* for
> "empty" strings
>
> Personally I am used to empty
>
> ObjectHelper.isNotNullOrNonEmpty(String s);
> And this cryptic name could be consider renamed to
>
> ObjectHelper.isNotEmpty(String s);
> ObjectHelper.isEmpty(String s);
>
> We could have just object parameters and if the type is a string we
> can do the cast to string and do the trim.length > 0 test.
> So we only have these two methods to remember
> ObjectHelper.isNotEmpty(Object s);
> ObjectHelper.isEmpty(Object s);
>
> They will test for null and trim strings if its a string type.
>
> Am I making myself clear?
>
>
> /Claus Ibsen
> Apache Camel Committer
> Blog: http://davsclaus.blogspot.com/
>


--
James
-------
http://macstrac.blogspot.com/

Open Source Integration
http://fusesource.com/
Reply | Threaded
Open this post in threaded view
|

Re: Empty or Blank - the choice is here now

Ramon Buckland
Would it not be better to just use commons-lang:StringUtils ?

http://commons.apache.org/lang/api/org/apache/commons/lang/StringUtils.html

Which has these all already defined  (thus consistent)

On Tue, Dec 9, 2008 at 18:58, <[hidden email]> wrote:

> Sounds good. By 'empty' we mean either null or zero length right?
>
>
> On 08/12/2008, Claus Ibsen <[hidden email]> wrote:
> > Hi
> >
> > Now that we have the chance to change the API for Camel 2.0 I have a
> > few very minor issues as well.
> >
> > We have methods on ObjectHelper for assertions of null and if strings
> > is provided or not.
> > We currently have a mix of String assertions methods that use *empty*
> > or *blank* to indicate if a string is provided or not.
> >
> > I think we should align and only use either *blank* or *empty* for
> > "empty" strings
> >
> > Personally I am used to empty
> >
> > ObjectHelper.isNotNullOrNonEmpty(String s);
> > And this cryptic name could be consider renamed to
> >
> > ObjectHelper.isNotEmpty(String s);
> > ObjectHelper.isEmpty(String s);
> >
> > We could have just object parameters and if the type is a string we
> > can do the cast to string and do the trim.length > 0 test.
> > So we only have these two methods to remember
> > ObjectHelper.isNotEmpty(Object s);
> > ObjectHelper.isEmpty(Object s);
> >
> > They will test for null and trim strings if its a string type.
> >
> > Am I making myself clear?
> >
> >
> > /Claus Ibsen
> > Apache Camel Committer
> > Blog: http://davsclaus.blogspot.com/
> >
>
>
> --
> James
> -------
> http://macstrac.blogspot.com/
>
> Open Source Integration
> http://fusesource.com/
>
Reply | Threaded
Open this post in threaded view
|

Re: Empty or Blank - the choice is here now

Claus Ibsen-2
In reply to this post by jstrachan
On Tue, Dec 9, 2008 at 8:58 AM,  <[hidden email]> wrote:
> Sounds good. By 'empty' we mean either null or zero length right?
Yes excatly.

On trunk I have added a variation of the notNull that accepts a 3rd
parameter to indicate a "at" or to append at.toString().
This is useful in the model package where we can report the type that
raised the problem (using it's nice toString)

So end users will get a little bit more help there.



>
>
> On 08/12/2008, Claus Ibsen <[hidden email]> wrote:
>> Hi
>>
>> Now that we have the chance to change the API for Camel 2.0 I have a
>> few very minor issues as well.
>>
>> We have methods on ObjectHelper for assertions of null and if strings
>> is provided or not.
>> We currently have a mix of String assertions methods that use *empty*
>> or *blank* to indicate if a string is provided or not.
>>
>> I think we should align and only use either *blank* or *empty* for
>> "empty" strings
>>
>> Personally I am used to empty
>>
>> ObjectHelper.isNotNullOrNonEmpty(String s);
>> And this cryptic name could be consider renamed to
>>
>> ObjectHelper.isNotEmpty(String s);
>> ObjectHelper.isEmpty(String s);
>>
>> We could have just object parameters and if the type is a string we
>> can do the cast to string and do the trim.length > 0 test.
>> So we only have these two methods to remember
>> ObjectHelper.isNotEmpty(Object s);
>> ObjectHelper.isEmpty(Object s);
>>
>> They will test for null and trim strings if its a string type.
>>
>> Am I making myself clear?
>>
>>
>> /Claus Ibsen
>> Apache Camel Committer
>> Blog: http://davsclaus.blogspot.com/
>>
>
>
> --
> James
> -------
> http://macstrac.blogspot.com/
>
> Open Source Integration
> http://fusesource.com/
>
Reply | Threaded
Open this post in threaded view
|

Re: Empty or Blank - the choice is here now

Claus Ibsen-2
In reply to this post by Ramon Buckland
Hi

If SUN just had much better String and other core utilities to it's
JDK itself !!!
How many people have created their own hasText, notNull, notBlank,
isXXX variations.

We can not use commons-lang as we want to keep camel-core.jar without
dependencies at all.
Currently it only requires commons-logging.jar



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



On Tue, Dec 9, 2008 at 9:03 AM, Ramon Buckland <[hidden email]> wrote:

> Would it not be better to just use commons-lang:StringUtils ?
>
> http://commons.apache.org/lang/api/org/apache/commons/lang/StringUtils.html
>
> Which has these all already defined  (thus consistent)
>
> On Tue, Dec 9, 2008 at 18:58, <[hidden email]> wrote:
>
>> Sounds good. By 'empty' we mean either null or zero length right?
>>
>>
>> On 08/12/2008, Claus Ibsen <[hidden email]> wrote:
>> > Hi
>> >
>> > Now that we have the chance to change the API for Camel 2.0 I have a
>> > few very minor issues as well.
>> >
>> > We have methods on ObjectHelper for assertions of null and if strings
>> > is provided or not.
>> > We currently have a mix of String assertions methods that use *empty*
>> > or *blank* to indicate if a string is provided or not.
>> >
>> > I think we should align and only use either *blank* or *empty* for
>> > "empty" strings
>> >
>> > Personally I am used to empty
>> >
>> > ObjectHelper.isNotNullOrNonEmpty(String s);
>> > And this cryptic name could be consider renamed to
>> >
>> > ObjectHelper.isNotEmpty(String s);
>> > ObjectHelper.isEmpty(String s);
>> >
>> > We could have just object parameters and if the type is a string we
>> > can do the cast to string and do the trim.length > 0 test.
>> > So we only have these two methods to remember
>> > ObjectHelper.isNotEmpty(Object s);
>> > ObjectHelper.isEmpty(Object s);
>> >
>> > They will test for null and trim strings if its a string type.
>> >
>> > Am I making myself clear?
>> >
>> >
>> > /Claus Ibsen
>> > Apache Camel Committer
>> > Blog: http://davsclaus.blogspot.com/
>> >
>>
>>
>> --
>> James
>> -------
>> http://macstrac.blogspot.com/
>>
>> Open Source Integration
>> http://fusesource.com/
>>
>