Serializar objetos de campo

I've written a generic database that indexes all the fields of an instance of a class that have a specific annotation. I need to be able to write an instance of this database to a file, but the Field object doesn't implement serializable and is final.

¿Hay alguna forma de evitar esto?


preguntado el 05 de mayo de 13 a las 15:05

1 Respuestas

You could get away with storing just the nombres of the fields (as strings, of course), since names must be unique within their declaring class. If you need to handle static members as well – and it's not clear that you do – store an additional isStatic boolean with each string.

contestado el 05 de mayo de 13 a las 15:05

Thanks for the reply! I'll give that a try - I don't need to handle static fields as I'm purely indexing an instance's unique fields. - rthur

So ... you're indexing the names of an objects instance fields ... but no data? - scottb

I'm also indexing the data, it's a simple implementation of an object DataBase with hashmaps. - rthur

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.