constructor - Groovy lazy object construction -


i have class can created passing list of strings or passing file. file parsed, creating list of strings. it's helper constructor.

parsing file may take long time , resulting list of strings may not used ever (even though object created anyways). therefore got idea of "lazy parsing" file file parsed right before methods of objects used.

is there way in groovy or better way achieve want?

i have used workaround now. save both file or string list given in 1 of constructors in fields (the other 1 null). create third lazy field accesses non-null-property (whatever is) , if it's file parses it.

that's rather complicated think it's way use lazyness arguments passed constructor shall lazily evaluated.


Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

Kivy: Swiping (Carousel & ScreenManager) -