-
Notifications
You must be signed in to change notification settings - Fork 2
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
Tuple convertor methods #17
Conversation
A tuple, e.g. a 2-ary Tuple, can be converterted to a an arbitrary instance using tuple.to((v1, v2) -> new Something(v1, v2), or more succinct: tuple.to(Something::new). This is a convenience API which eliminates the need to "manually extract" each value of the tuple, and instead either freely name the values with a lambda, or directly have the values passed to a method reference with the equivalent parameter signature as the parameterized types of the tuple.
Changes in license headers in .java files is because mathieucarbou/license-maven-plugin#118
It's is not available to resolve previous version itself when we use non-numeric LOCAL-SNAPSHOT for building Run with: mvn japicmp:cmp -Djapicmp.oldversion=<last released version>
import java.util.List; | ||
import java.util.UUID; | ||
|
||
final class Compound { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is just a dummy class used to test converting from XTuple
to an arbitrary type.
Kult det console-scriptet! :D |
Jepp, det er aktuelt i noen sammenhenger 😅 |
I Digg this. 🥇 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
New feature:
Add facility to convert tuples (triples, quadruples, etc) to arbitrary instances using either method references (typically a constructor
A::new
) having the same parameter type signature as the parameterized types of the tuple, or a lambda. Using a lambda enables arbitrary naming when referring to the constituents of the tuple, and a method reference offers a succinct conversion without needing to refer to internals of the tuple at all.As usual, the use of tuples should only be used by particularly general code. Most often a custom class with fields offering more semantics of the values is in order.
To only view these changes, look at 921a2de
Additional changes
All of the .java sources are touched because of a change in the license-maven-plugin, and can basically be ignored, as they all have this as their only diff:
To get a head-start with the review, paste this script into devtools console, hit Enter, and it will mark all this noise as "viewed" and collapse these files.