tvinke / bulletproof Goto Github PK
View Code? Open in Web Editor NEWGroovy AST transformations, such as @ValueObject and @NonNull, which makes constructing an instance more bullet-proof.
License: Apache License 2.0
Groovy AST transformations, such as @ValueObject and @NonNull, which makes constructing an instance more bullet-proof.
License: Apache License 2.0
Just read your post on Java Code Geeks.
In my own code, I designed an immutable class not using the @Immutable
annotation because I didn't think it allowed one to add setters to an immutable object:
public class Person {
String name;
int age;
// setter
Person setName(String newName) {
new Person(newName, age)
}
Would you be interested in adding these "immutable setters" (not sure what else to call them) or some Groovy counterpart to @ValueObject
? Or perhaps adding another annotation that combines ValueObject
with this idea? I would roll my own annotation, but I haven't yet learned how to do that myself.
I got a comment from @daviddawson on the Groovy Slack channel that
purely from an from an API usage point of view,
@Value
seems like a generic term, I wouldn't know what it meant if I came across that in code.
May be @Value
should be renamed to @ValueObject
, inspite of being inspired by Lombok similarly-named annotation, to clearly indicate it's role.
Have the default Map constructor also check for null
values.
@tvinke.bulletproof.transform.NonNull
class Person {
String name
}
new Person() // should also throws IllegalArgumentException: "Name can not be null"
For the class
@Immutable
@NonNull
class Person {
String name
int age /* primitive */
}
no null
check need to be performed for age
since it's a primitive.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.