Add @ConstructorProperties to generated constructor #195

Closed
lombokissues opened this Issue Jul 14, 2015 · 6 comments

Projects

None yet

2 participants

@lombokissues
Collaborator

Migrated from Google Code (issue 122)

@lombokissues
Collaborator

๐Ÿ‘ค jonathancrosmer@hotmail.com ย  ๐Ÿ•— May 19, 2010 at 14:46 UTC

@ ConstructorProperties is a new annotation in Java 6.
http://java.sun.com/javase/6/docs/api/java/beans/ConstructorProperties.html

The most obvious use of this annotation is that it enables XmlEncoder
to automatically encode immutable POJOs as XML (normally, XmlEncoder
can't encode immutable objects without special handling).

The constructor generated by @ Data should automatically add this
annotation. For example,

@ Data
class Point { private final int x, y; }

...becomes...

class Point {
@ ConstructorProperties({"x", "y"})
public Point(int x, int y) {
...
}

@lombokissues
Collaborator

๐Ÿ‘ค r.spilker ย  ๐Ÿ•— May 20, 2010 at 08:47 UTC

Thanks, Jonathan, for submitting this feature request. Looks like a great addition to
Lombok to me.

@lombokissues
Collaborator

๐Ÿ‘ค r.spilker ย  ๐Ÿ•— May 20, 2010 at 08:48 UTC

@lombokissues
Collaborator

๐Ÿ‘ค reinierz ย  ๐Ÿ•— Jul 19, 2010 at 21:50 UTC

We've added this feature to 0.9.3 (Burrowing Whale)!

There's still the issue that such a file won't compile on java 1.5, as @ ConstructorProperties is new in java 1.6. It can be suppressed with @ RequiredArgsConstructor(suppressConstructorProperties=true), though we've already deprecated that feature as we intend to remove it once 1.5 fades into the limelight.

Done in commit 5c6fe62

Leaving this issue open until we update the web docs

@lombokissues lombokissues added this to the 0.9.3 milestone Jul 14, 2015
@lombokissues
Collaborator

๐Ÿ‘ค reinierz ย  ๐Ÿ•— Jul 20, 2010 at 05:43 UTC

Docs have been updated in aaf8547

@lombokissues lombokissues removed the accepted label Jul 14, 2015
@lombokissues
Collaborator

End of migration

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment