1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package com.linecorp.centraldogma.client.updater;
17
18 import java.lang.reflect.Method;
19
20 import javax.annotation.Nullable;
21
22 import com.linecorp.centraldogma.common.Revision;
23
24 final class RevisionMethodDelegate implements MethodDelegate {
25 @Override
26 public boolean match(Method thisMethod) {
27 return thisMethod.getReturnType() == Revision.class &&
28 thisMethod.getParameterCount() == 0;
29 }
30
31 @Override
32 @Nullable
33 public <T> Object invoke(CentralDogmaBeanMethodHandler<T> handler, Object self, Method thisMethod,
34 Method proceed, Object[] args) throws Throwable {
35 if (handler.watcher.initialValueFuture().isDone()) {
36 return handler.watcher.latest().revision();
37 } else {
38 return null;
39 }
40 }
41 }