Re-hydration from previous state
pocesar opened this issue · 2 comments
Right now, I'm accessing the "private" members directly, and assigning them manually. would be good to have an static method, like fromJSON(theOneReturnedFromtoJSON)
to initialize the classes using a previous state.
This sounds reasonable. I really dislike the method name toJson
that all the metrics impl, because some of them do NOT return JSON, should really be getValue()
or getPayload()
.
Since this lib is inspired from Dropwizard see: https://github.com/dropwizard/metrics/blob/4.1-development/metrics-core/src/main/java/com/codahale/metrics/Gauge.java#L25
So maybe the static initializer could be fromValue
.
recreating the internal representation is harder than I expected, there are too many moving parts (new class instances, and their internals as well)