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

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -