Javadoc
Adapted from * Google GSON's RuntimeTypeAdapterFactory to support a field based adapter. Instead of adding a new
field to the top level, this takes a list of values that the field can be in order to decide which TypeAdapter to
use. The field itself is represented as a passed in Function that operates on a JsonElement and returns a String.
You can compute your field based on the JsonElement and return a String value. Subtypes can then be registered
with a list of String values that this extracted field is checked against.
When deserializing JSON, the field is extracted from it using the provided Function, checked to see if it is
present in the List of values for a subtype (in order of registry), if it is, the JSON is attempted to be
deserialized into that subtype (and returned as an element of the base type
T).
Serializing JSON is done as normal without any changes to the output JSON.
RuntimeTypeAdapterFactory instead uses an additional field to carry the type information.