commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stephen Colebourne <scolebou...@joda.org>
Subject Re: svn commit: r989199 - in /commons/proper/lang/trunk/src: main/java/org/apache/commons/lang3/SerializationUtils.java test/java/org/apache/commons/lang3/SerializationUtilsTest.java
Date Thu, 26 Aug 2010 10:48:41 GMT
On 26 August 2010 11:29, James Carman <james@carmanconsulting.com> wrote:
> This way, you could do:
>
> Person p = SerializableUtils.deserialize(bytes);
>
> No casting!  Now, if the bytes don't represent a Person object, then
> you'll get a ClassCastException, but that's exactly the same thing
> that would happen if you did this (with the current API):
>
> Person p = (Person)SerializableUtils.deserialize(bytes);
>
> So, we make it easier to use the API by avoiding a cast.
I add this "auto-cast" behaviour to some of my classes too. Its a
useful technique to handle annoying cases. However, the alternative:
 Person p = SerializableUtils.deserialize(Person.class, bytes);
is more widely used.

Stephen

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


Mime
View raw message