hf / immu Goto Github PK
View Code? Open in Web Editor NEWNever write an immutable object by hand.
License: MIT License
Never write an immutable object by hand.
License: MIT License
Provide @Nullable
and @NonNull
annotation for the getter methods depending on their @Required
annotation
Type wrappers usually serve the purpose of wrapping an existing type with a different type in order to better convey meaning. For example, if an object has a unique identifier, usually that would be a String
. However, it is a special kind of String
. Using it all over the place to refer to the unique identifier is a code smell: it can lead to errors (what id was it?), and it is not descriptive. One can utilize a type wrapper around that String to standardize the usage of the unique identifier as a UniqueIdentifier
.
@Immu
interface UniqueIdentifer {
@Required String identifier();
}
It is slightly bothersome to write UniqueIdentifierBuilder.create().identifier(theIdentifier).build()
to create an instance of UniqueIdentifier
.
Use UniqueIdentifierBuilder.create(theIdentifier) => UniqueIdentifier
for this use case:
Immu
has only one propertyRequired
Add support for Optional-like types in interfaces. Those will not be compatible with @Required
.
Currently all @Required
properties will be present, in order, in the generated builder's creator as parameters. This has a few drawbacks:
@Required
then the argument list is too longA solution to this would be to generate a parameterless create()
method and lazily verify that the @Required
properties have been supplied to the builder when build()
will be called.
An efficient implementation would be to store an array of int
s. Each int
is a bit-field representing at most 32 properties. The int
s are initialized to ~0
and each property gets a unique bit in a specific int position. The first time a property is set on the builder, its bit is flipped to 0
. Upon build()
iterate over the few integers representing all required properties and throw an exception if not all int
s are 0
.
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.