Created
July 29, 2013 14:07
-
-
Save melix/6104533 to your computer and use it in GitHub Desktop.
Immutable+Newify+CompileStatic
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
import groovy.transform.* | |
@Immutable class Coordinates { | |
double latitude, longitude | |
} | |
@Immutable class Path { | |
Coordinates[] coordinates | |
} | |
@Newify([Coordinates, Path]) | |
@CompileStatic | |
def build() { | |
Path( | |
Coordinates(48.824068d, 2.531733d), | |
Coordinates(48.857840d, 2.347212d), | |
Coordinates(48.858429d, 2.342622d) | |
) | |
} | |
assert build().coordinates.size() == 3 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment