android - How Can I Override Library Methods in Java? -


i'm working on large android project using gson. method fromjson() called dozens of times in many files. need provide special-case tests every time method called.

rather going through , repeating tests each , every time method used, i'd follow dry doctrine , override fromjson() method somehow.

my first thought make child class of gson , override method, still have make dozens (perhaps hundreds) of changes make work. if willing work, gson final , can't extended.

second thought: might possible alter gson library code. don't want go route i'm afraid may break otherwise works perfectly.

this area of java have never ventured before. have suggestions?

since there no responses, i'm going go ahead , give own answer.

if library class/method declared final, whole point never inherit or override said class. , since it's library (and don't have access source), there no way change it.

  • solution #1: write own library. of course defeats entire purpose of using libraries (to keep having re-invent wheel).

  • solution #2: find work-around. hack-y sounds, reasonable choice.

  • solution #3: live bug/error/lack-of-feature. not issues show-stoppers. might able have great program still doesn't live every desired detail.

  • solution #4: abandon project. may viable option. not me @ time.


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - Bypass Geo Redirect for specific directories -

php - .htaccess mod_rewrite for dynamic url which has domain names -