java - Retrieve values from class: custom methods or reflection? -


for take values ​​from class there primitive fields (no methods) list of key - value prefer use reflection (with dynamic iteration) or specific method return hashmap? prefer?

at moment there fifty classes or in future can grow twenty or thirty (in regime)

i reflection in case not necessary?

the reflection-based approach cleaner, because not require classes implement additional methods, , not liable maintain these methods when new fields added existing classes.

a hashmap-based approach not buy in terms of performance, because primitives must wrapped in objects inserted map - same way wrapped returned reflection-based calls.


Comments

Popular posts from this blog

pentaho - Carte Status / Kettle Slave Server Status page shows status for random runs instead of the latest run -

R summary function in ddply (plyr) in a simple way -

c# - Are delegates created via lambda expressions guaranteed to be cached? -