Last active
December 14, 2015 16:28
-
-
Save mike-neck/5114818 to your computer and use it in GitHub Desktop.
This file contains 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
/** | |
* GroovyASTTransformation の お話 | |
* | |
* Annotation Based AST Transformations | |
* | |
* AST にアクセスする一つの手段が Annotation を介してアクセスする方法。 | |
**/ | |
/** | |
* 例 3 : @Canonical | |
**/ | |
import groovy.transform.* | |
@Canonical | |
@EqualsAndHashCode (excludes = ['year', 'model']) | |
class Car { | |
String VIN | |
String engineNumber | |
int year | |
String model | |
} | |
def celsior = new Car ( | |
VIN : 'UCF11989X02254931', | |
engineNumber : '1UZFE-083566', | |
year : 1998, | |
model : 'Celsior') | |
def crown = new Car ( | |
VIN : 'S140C989X00344259', | |
engineNumber : '1UZFE-092317', | |
year : 1998, | |
model : 'Crown Magesta') | |
assert celsior != crown | |
def century = new Car ( | |
VIN : 'UCF11989X02254931', | |
engineNumber : '1UZFE-083566', | |
year : 2004, | |
model : 'Century') | |
assert celsior != century |
This file contains 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
Assertion failed: | |
assert celsior != century | |
| | | | |
| | Car(UCF11989X02254931, 1UZFE-083566, 2004, Century) | |
| false | |
Car(UCF11989X02254931, 1UZFE-083566, 1998, Celsior) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment