commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Verneri Ã…berg <verneri.ab...@gmail.com>
Subject [lang]Question about StringUtils chomp and removeEnd
Date Wed, 24 Aug 2011 06:02:23 GMT
Hi all,

I was just browsing through StringUtils Api (versions 2.5, 2.6 and
3.0.1) and found two very similar looking methods

chomp(String,String)
and
removeEnd(String, String)

So I started to wonder what is the difference here and looked at the
source code.

To my astonishment the only difference is that chomp returns the source
string immediately if the removed string is null and remove end
additionally checks for empty strings too.

So wouldn't it be better to substitute the duplication by simply
replacing the chomp method with following version?

public String chomp(String source, String separator) {
	return removeEnd(source,separator);
}

Or is there some hidden idea for two different implementations of the
same string chompping function? if there is maybe it should be added to
both methods javadocs?

 Verneri


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Mime
View raw message