0

For example, instance of the following following class produces string A(x:7, values:[hello, world])

@ToString( includeNames=true )
class A {
    def x
    def values = []
}

How can I transform this String back to an instance of the class?

kaskelotti
  • 4,709
  • 9
  • 45
  • 72
  • 1
    you would have to parse it and this is extremly error prone (set `values=['hello, world']` and see it fall apart). – cfrick Feb 05 '15 at 13:59
  • @dmahapatro At the moment that's how some results are written on the log. Loggin in JSON format is on the way, but I need to do some analysis based on the earlier results. As the software is written with Groovy I thought I could skip some regexp parsing. – kaskelotti Feb 05 '15 at 16:02
  • if the output would have been generated with `inspect()` you could use `Eval` (with all the pain, that would bring) – cfrick Feb 05 '15 at 16:22

1 Answers1

0

Based on the comments by @cfrick, this is not possible.

(Answering my own question for the sake of closing this topic.)

kaskelotti
  • 4,709
  • 9
  • 45
  • 72