Skip to content

Persisting / Restoring Subclass of java.util.LinkedHashMap #510

Answered by hg-ms
Haribou asked this question in Q&A
Discussion options

You must be logged in to vote

The problem arises because you extended the LinkedHashMap class. The LinkedHashMap requires a specialized type-handler because of its complexity that can’t be handled by our generic type-handler any more.
The private SetFromMap type retuned from Collections.newSetFromMap() may need a custom type- handler too.

You have two options to solve that:

  1. Write a custom type-handlers for your LimitedSet class and SetFromMap class. But be aware that might be a very challenging task.
  2. Instead of extending the LinkedHashMap use a composition. That way you can avoid writing custom type handlers. This is most likely the simplest solution.

When using the HashSet everything works because we provide a spec…

Replies: 3 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by Haribou
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@hg-ms
Comment options

hg-ms Jan 24, 2023
Collaborator

@Haribou
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants