File tree Expand file tree Collapse file tree 1 file changed +10
-8
lines changed Expand file tree Collapse file tree 1 file changed +10
-8
lines changed Original file line number Diff line number Diff line change
1
+ import lombok .AccessLevel ;
2
+ import lombok .RequiredArgsConstructor ;
3
+ import lombok .experimental .FieldDefaults ;
4
+
1
5
import java .util .concurrent .locks .ReadWriteLock ;
2
6
import java .util .function .Supplier ;
3
7
4
8
/**
5
9
* Created by mtumilowicz on 2019-01-07.
6
10
*/
7
- public class LockExecutor {
8
- private final ReadWriteLock lock ;
9
-
10
- LockExecutor (ReadWriteLock lock ) {
11
- this .lock = lock ;
12
- }
11
+ @ FieldDefaults (makeFinal = true , level = AccessLevel .PRIVATE )
12
+ @ RequiredArgsConstructor
13
+ class LockExecutor {
14
+ ReadWriteLock lock ;
13
15
14
- public void write (Runnable action ) {
16
+ void write (Runnable action ) {
15
17
lock .writeLock ().lock ();
16
18
try {
17
19
action .run ();
@@ -20,7 +22,7 @@ public void write(Runnable action) {
20
22
}
21
23
}
22
24
23
- public <T > T read (Supplier <T > action ) {
25
+ <T > T read (Supplier <T > action ) {
24
26
lock .readLock ().lock ();
25
27
try {
26
28
return action .get ();
You can’t perform that action at this time.
0 commit comments