commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oliver Heger <oliver.he...@oliver-heger.de>
Subject Re: [configuration2]: AbstractConfiguration::getArray
Date Wed, 27 Apr 2016 19:35:18 GMT
Hi Rainer,

Am 27.04.2016 um 21:22 schrieb Rainer Hirschmiller:
> Hi.
> 
> I wonder why AbstractConfiguration::getArray(cls, key) returns a single
> object, not an array of objects? Can somebody explain why the caller
> have to make an explicit cast?
> 
> e.g.
> AbstractConfiguration &configuration = ....;
> 
> Object obj = configuration.getArray(String.class, "key);
> // expected Object[] obj = configuration.getArray(String.class, "key);
> 

the explanation can be found in the Javadocs of the ConversionHandler
interface which is used behind the scenes. Citing from the docs of the
toArray() method:

"Note that the result type of this method is Object; because this method
can also produce arrays of a primitive type the return type Object[]
cannot be used."

Oliver

> 
> Regards
> Rainer
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
> 

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


Mime
View raw message