más rápido serializar XML usando toString y deserializar usando el constructor de cadenas
Tengo un POJO que se parece a esto:
public class Thing
{
private final int x;
private final int y;
private final int z;
public Thing(String strThing)
{
// parse strThing which is in some arbitrary format to set x, y and z
}
@Override
public String toString()
{
// return a string representation of thing
// (same format as that parsed by the constructor)
}
@Override
public boolean equals(Object obj) ...
@Override
public int hashCode() ...
}
y quiero usarlo como clave para un mapa (p. ej.HashMap<Thing, SomeOtherPOJO>
) que, al serializar a json, usa la representación toString () de Thing para la clave, y cuando se deserializa, usa el constructor String. ¿Es esto posible usando algo simple como las anotaciones de enlace de datos de Jackson? ¿Cuál sería la mejor manera de abordar esto?