Comments (12)
I can confirm that your latest commits fix my use cases above. Nice job, especially considering that I've reported the bug just an hour ago! Thanks!
from immutables-vavr.
Seems like a low-cost change to improve serialization. I'll add it now.
from immutables-vavr.
This may be corrected in the 0.4.0-SNAPSHOT
I just pushed.
from immutables-vavr.
It indeed seems to be fixed for Option
! But, it is not limited to Option
s: List
, Map
, Set
, and probably others, also seem to be affected.
from immutables-vavr.
Is it the same error for the List
, Map
, etc, types?
Error:java: Could not generate constructor. Attribute 'bar' does not have default value.
I have to admit that I don't fully understand the underlying issue. If all that's needed to fix it is adding @Encoding.Copy
methods, then I can easily get that done.
from immutables-vavr.
Yes, it is the same error. With the latest version from branch develop
:
@Value.Immutable
@VavrEncodingEnabled
@JsonSerialize
@JsonDeserialize
public interface Foo {
Option<String> option();
List<String> list();
Set<String> set();
Map<String, Integer> map();
}
Results in the compiler errors:
Error:java: Could not generate constructor. Attribute 'list' does not have default value.
Error:java: Could not generate constructor. Attribute 'set' does not have default value.
Error:java: Could not generate constructor. Attribute 'map' does not have default value.
Option is fixed now, and JSON encoding/decoding also works.
from immutables-vavr.
Ah, so presumably it's just a matter of providing a default value for the @Encoding.Impl
field. I'll update all of the types now.
from immutables-vavr.
Have a go with the snapshot I just pushed (20170702.120216
).
from immutables-vavr.
I'll likely push a release today if @emmanueltouzery confirms the snapshot as working.
from immutables-vavr.
hmm i won't manage to test it today. tomorrow best case. i'd say go for it. i think in the case of our setup, we'll probably stick with a small-scale local implementation which supports only option, which is enough for us, we probably won't migrate to using this library.
from immutables-vavr.
Got it!
from immutables-vavr.
Great! 👍
Just one thing: I've noticed that you've introduced empty HashSet
and HashMap
as default values for Set
and Map
. Usually, I prefer to use the Linked
versions of these classes, as they have a useful ordering semantics: converting JSON to some object and back again leads to the same JSON. This makes it easier to write tests, and also to compare for differences in case something fails (which is difficult if the ordering of elements is arbitrary).
What do you think? Does it make sense to you to use LinkedHash[Set/Map]
as defaults?
To me, it's not a serious issue what the defaults are, as I can always just directly use the type LinkedHash[Set/Map]
in my immutable data types, though I'd prefer not to, as LinkedHash
adds 10 more characters. :(
from immutables-vavr.
Related Issues (20)
- Question: Why is there no VavrSetEncodingEnabled? HOT 3
- Customized with() methods HOT 1
- Builder.add with VarArgs HOT 1
- Publish as a Java 9 module HOT 1
- Modularize! HOT 2
- Failing builds HOT 3
- Options appearing wierdly in builder HOT 7
- Correct module name
- inhibit-classpath is too aggressive HOT 4
- vavr 1.0.0 is due out soon HOT 1
- Make VavrMapEncoding consistent with immutables naming HOT 1
- Make Option's "with" method behaviour consistent with builder logic HOT 1
- Option type fields allow nulls HOT 7
- Migrate to Github Actions
- @Value.Default with Option-fields throws NullPointerException HOT 1
- NullPointerException in equals(), hashCode() and toString() with @Nullable Vector. HOT 3
- Multimap needs proper support HOT 4
- Upload the releases to maven central HOT 2
- Option builder fields are not generated for Stage builders / values HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from immutables-vavr.