Giter Site home page Giter Site logo

Comments (8)

Querz avatar Querz commented on June 12, 2024 1

See #27
Comparable is only implemented by Tags that need it. Implementing Comparable for EndTag didn't really make sense :)

from nbt.

Querz avatar Querz commented on June 12, 2024

compareTo should throw an exception when comparing incompatible types. See #27.

from nbt.

Marcono1234 avatar Marcono1234 commented on June 12, 2024

But why is Comparable needed on Tag level anyways? Would there be any problems when moving it the respective classes (except compatibility)?

from nbt.

Querz avatar Querz commented on June 12, 2024

I just saw that i forgot to add a ListTag#sort() for which this was originally intended. In this case it makes sense to have every tag (or their abstract parent class, like ArrayTag or NumberTag) implement Comparable.

from nbt.

Marcono1234 avatar Marcono1234 commented on June 12, 2024

This should also be possible using sort(Comparator.naturalOrder()), but would of course be more to type.

from nbt.

Querz avatar Querz commented on June 12, 2024

For sort(Comparator.naturalOrder() to work i would need to implement Comparable for every tag anyway.
Or is your point to have some tags not comparable at all, because it might not make much sense (e.g. comparing CompoundTag)?

from nbt.

Marcono1234 avatar Marcono1234 commented on June 12, 2024

Using sort(Comparator.naturalOrder()) would only require that the currently used element type implements Comparable.

My goals are to

  • Not force implementing Comparable where it does not make sense or will only be useful for a very specific use case (CompoundTag)
  • Make compareTo more type-safe and prevent comparing incompatible types at compile time

from nbt.

Marcono1234 avatar Marcono1234 commented on June 12, 2024

I am still not sure if the implementations for the array, list and compound tags are not too specific and tailored to a specific use case only.
But this is definitely better, thanks!

from nbt.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.