diff options
author | nea <nea@nea.moe> | 2023-04-06 00:34:41 +0200 |
---|---|---|
committer | nea <nea@nea.moe> | 2023-04-06 01:04:06 +0200 |
commit | 83c63686d7ef6c745ed9d853e33c293f7d6bb8d5 (patch) | |
tree | 30d84f0d61b532d92b12de18335602076973e091 /test/eclipse/resource/select/builderField | |
parent | b80ff39d82cadf5f61e65e022d6e828496b091ef (diff) | |
download | lombok-feat/memoize.tar.gz lombok-feat/memoize.tar.bz2 lombok-feat/memoize.zip |
Initial draft for @lombok.experimental.Memoizefeat/memoize
This is an initial draft for how an @Memoize annotation could look like.
It currently lacks features such as:
- Thread safety
- Cache invalidation
- Soft/Weak References for a lower memory profile
- Avoiding using a Map entirely for parameterless methods
Ideally at least some of these properties should be configurable using
flags and/or annotation properties (some users might prefer a non
thread safe cache for better performance).
Example Usage:
```java
class Test {
int invocationCount = 0;
public static void main(String[] args) {
Test test = new Test();
System.out.println(test.x(1, 2));
System.out.println(test.x(1, 2));
System.out.println(test.x(1, 3));
System.out.println("Invocation Count: " + test.invocationCount);
}
@lombok.experimental.Memoize
public int x(int y, int z) {
invocationCount++;
return y + z;
}
}
```
Diffstat (limited to 'test/eclipse/resource/select/builderField')
0 files changed, 0 insertions, 0 deletions