Closed Querz closed 5 years ago
These points do not apply anymore
- ListTag and CompoundTag should throw an exception when comparing them with incompatible types
- ListTag and CompoundTag should always clear their values before deserialising data into them
- Add ListTag#sort() to make use of the implementation of Comparable in each tag
And you could change NumberTag
and ArrayTag
to be type-safe for compareTo
at the cost of a slightly more complicated signature:
public abstract class NumberTag<T extends Number & Comparable<T>, ThisTagType extends NumberTag<T, ?>> extends Tag<T> implements Comparable<ThisTagType> {
And then have subclasses add their own type as ThisTagType
:
public class ByteTag extends NumberTag<Byte, ByteTag>
Though this makes using NumberTag
more unpleasant. Maybe it would be best to just only have the subclasses (e.g. ByteTag
) implement Comparable and not NumberTag
.
The changes look good. Thank you very much!
This pull request fixes some issues regarding inconsistency.
Comparable
on their own to assure type safetyListTag
andCompoundTag
now always clear their values before deserialising data into themTag#toString()
andTag#toTagString()
are nowfinal
to force child classes to use themaxDepth
parameternull
to#compareTo
now throws aNullPointerException
ListTag
andStructTag
sizes are corrected to0
Tag#getEmptyValue()