-
Notifications
You must be signed in to change notification settings - Fork 270
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
Add helper methods to CustomValue and its implementations #338
base: master
Are you sure you want to change the base?
Conversation
src/main/java/net/fabricmc/loader/api/metadata/CustomValue.java
Outdated
Show resolved
Hide resolved
src/main/java/net/fabricmc/loader/api/metadata/CustomValue.java
Outdated
Show resolved
Hide resolved
src/main/java/net/fabricmc/loader/api/metadata/CustomValue.java
Outdated
Show resolved
Hide resolved
src/main/java/net/fabricmc/loader/api/metadata/CustomValue.java
Outdated
Show resolved
Hide resolved
src/main/java/net/fabricmc/loader/metadata/CustomValueImpl.java
Outdated
Show resolved
Hide resolved
src/main/java/net/fabricmc/loader/api/metadata/CustomValue.java
Outdated
Show resolved
Hide resolved
src/main/java/net/fabricmc/loader/metadata/CustomValueImpl.java
Outdated
Show resolved
Hide resolved
The custom value's status as not being value-based should be a bug. @sfPlayer1 What's your view on this whole thing? Will you include the new utilities besides fixing the value-based nature of these classes? |
@sfPlayer1 Even though the addition of stream methods are actually optional (as they can always stream an iterable), I wonder if we want to treat our custom values as data classes (as opposed to identity objects as they are right now) |
Not sure, it's really just a simple way to expose the data from the mod jsons. Implementing toString has some benefits in the debugger, but uses that depend on equals/hashCode having specific semantics are unclear. |
CustomValue
's implementations do not implementequals
orhashCode
. This causes issues when storing them in lists and maps, where it is impossible to removeCustomValue
s from a list, or get the value associated with aCustomValue
key from a map.This also affects any
DynamicOps
relying onCustomValue
s asFieldDecoder
s get returnednull
when reading a CustomValue keyed map.This makes
CustomValue
's implementations implementequals
,hashCode
andtoString
.This also adds a
stream
method to CvObject and CvArray, and akeySet
method toCvObject
for convenience.