Last active
December 20, 2015 03:28
-
-
Save gunnarmorling/6063349 to your computer and use it in GitHub Desktop.
Options for configuring group conversions via the API (https://hibernate.atlassian.net/browse/HV-642)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ConstraintMapping mapping = config.createConstraintMapping(); | |
mapping.type( GreetingService.class ) | |
.method( "greet", User.class ) | |
.returnValue() | |
.valid() | |
.convertGroup( Default.class ).to( User.class ) | |
.convertGroup( Foo.class ).to( Bar.class ); | |
//more "fluent" name? | |
ConstraintMapping mapping = config.createConstraintMapping(); | |
mapping.type( GreetingService.class ) | |
.method( "greet", User.class ) | |
.returnValue() | |
.valid() | |
.convertingFrom( Default.class ).to( User.class ) | |
.convertingFrom( Foo.class ).to( Bar.class ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//using an object for representing conversions | |
ConstraintMapping mapping = config.createConstraintMapping(); | |
mapping.type( GreetingService.class ) | |
.method( "greet", User.class ) | |
.returnValue() | |
.valid() | |
.convertGroup( new GroupConversion( Default.class, User.class ) ) | |
.convertGroup( new GroupConversion( Foo.class, Bar.class ) ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//using an object within valid(GroupConversion... conversions) | |
ConstraintMapping mapping = config.createConstraintMapping(); | |
mapping.type( GreetingService.class ) | |
.method( "greet", User.class ) | |
.returnValue() | |
.valid( | |
new GroupConversion( Default.class, User.class ), | |
new GroupConversion( Foo.class, Bar.class ) | |
); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ConstraintMapping mapping = config.createConstraintMapping(); | |
mapping.type( GreetingService.class ) | |
.method( "greet", User.class ) | |
.returnValue() | |
.valid() | |
.withConversion( Default.class, User.class ) | |
.withConversion( Foo.class, Bar.class ); |
For some reason, I am hesitant to link group conversion to the valid call. Granted that's the case in the spec but we decided to leave them separate annotation wise.
1a has my preference.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
On first impulse 3 or 1a