Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve overall type safety #21

Closed
Querz opened this issue Dec 13, 2018 · 2 comments
Closed

Improve overall type safety #21

Querz opened this issue Dec 13, 2018 · 2 comments

Comments

@Querz
Copy link
Owner

Querz commented Dec 13, 2018

As the main issue is type safety, I think it will be best to combine #20 and #14 into one pr (#18 ).

Summary:

  • Fix excessive use of raw types especially for Tag and ListTag
  • You should not be able to change the type of a ListTag after a type has been specified
  • ListTags of type EndTag should not be allowed
  • Handle ListTag#equals(), ListTag#clone() and ListTag#compareTo() correctly
  • Handle serialisation and deserialisation correctly with the above changes
  • Adjust Unit Tests accordingly
@Marcono1234
Copy link
Contributor

Currently a deserialized list (empty or not) can be cast to any typed list due to only the typeID being set. It would probably be good to add lookup functionality to TagFactory. This way the respective class could be retrieved for the typeID.

Additionally it would allow setting the typeID based on the class when the list is constructed and not having to wait for the first element. At this point it might even be worth it removing the typeID field completely and only retrieving it from the TagFactory when needed, performing all type checks only with the type class.

@Querz
Copy link
Owner Author

Querz commented Dec 20, 2018

The typeID has been removed and the ListTag's type is only defined by a type class now.
TagFactory now has additional lookup functionality to get type ids from classes, classes from type ids and factory functions to create new instances of Tags from type ids.

All the new changes are available in release 3.0.

@Querz Querz closed this as completed Dec 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants