1 | package com.github.dakusui.osynth.core; | |
2 | ||
3 | import java.lang.reflect.InvocationHandler; | |
4 | import java.lang.reflect.Method; | |
5 | import java.util.Map; | |
6 | import java.util.concurrent.ConcurrentHashMap; | |
7 | ||
8 | import static com.github.dakusui.osynth.core.utils.MethodUtils.execute; | |
9 | import static com.github.dakusui.osynth.core.utils.MethodUtils.toEmptyArrayIfNull; | |
10 | ||
11 | public interface InvocationController extends InvocationHandler { | |
12 | Object[] EMPTY_ARGS = new Object[0]; | |
13 | ||
14 | @Override | |
15 | default Object invoke(Object proxy, Method method, Object[] args) { | |
16 |
1
1. invoke : removed call to com/github/dakusui/osynth/core/InvocationContext$Impl::contextWith → KILLED |
InvocationContext.Impl.contextWith(method); |
17 |
2
1. invoke : replaced return value with null for com/github/dakusui/osynth/core/InvocationController::invoke → KILLED 2. lambda$invoke$0 : replaced return value with null for com/github/dakusui/osynth/core/InvocationController::lambda$invoke$0 → KILLED |
return execute(() -> methodHandlerFor(method).handle((SynthesizedObject) proxy, toEmptyArrayIfNull(args))); |
18 | } | |
19 | ||
20 | MethodHandler methodHandlerFor(Method method); | |
21 | ||
22 | MethodHandler figuredOutMethodHandlerFor(Method invokedMethod); | |
23 | ||
24 | SynthesizedObject.Descriptor descriptor(); | |
25 | ||
26 | static InvocationContext invocationContext() { | |
27 |
1
1. invocationContext : replaced return value with null for com/github/dakusui/osynth/core/InvocationController::invocationContext → KILLED |
return InvocationContext.forCurrentThread(); |
28 | } | |
29 | ||
30 | interface WithCache extends InvocationController { | |
31 | /** | |
32 | * Returns a newly created map object used for method handler cache. | |
33 | * | |
34 | * Default implementation of this method returns a new {@link ConcurrentHashMap} | |
35 | * object. | |
36 | * Assign the returned map of this method to a field returned by | |
37 | * {@link InvocationController.WithCache#cache()} method. | |
38 | * | |
39 | * @return A new map for method handler cache. | |
40 | */ | |
41 | default Map<Method, MethodHandler> createCache() { | |
42 |
1
1. createCache : replaced return value with Collections.emptyMap for com/github/dakusui/osynth/core/InvocationController$WithCache::createCache → KILLED |
return new ConcurrentHashMap<>(); |
43 | } | |
44 | ||
45 | /** | |
46 | * Returns an already created map object to be used for a method handler cache. | |
47 | * | |
48 | * @return A map for method handler cache. | |
49 | */ | |
50 | Map<Method, MethodHandler> cache(); | |
51 | ||
52 | default MethodHandler methodHandlerFor(Method method) { | |
53 |
1
1. methodHandlerFor : replaced return value with null for com/github/dakusui/osynth/core/InvocationController$WithCache::methodHandlerFor → KILLED |
return cache().computeIfAbsent(method, this::figuredOutMethodHandlerAndApplyDecorator); |
54 | } | |
55 | ||
56 | default MethodHandler figuredOutMethodHandlerAndApplyDecorator(Method method) { | |
57 |
1
1. figuredOutMethodHandlerAndApplyDecorator : replaced return value with null for com/github/dakusui/osynth/core/InvocationController$WithCache::figuredOutMethodHandlerAndApplyDecorator → KILLED |
return descriptor() |
58 | .methodHandlerDecorator() | |
59 | .apply(method, figuredOutMethodHandlerFor(method)); | |
60 | } | |
61 | } | |
62 | ||
63 | abstract class Base implements InvocationController { | |
64 | private final SynthesizedObject.Descriptor descriptor; | |
65 | ||
66 | protected Base(SynthesizedObject.Descriptor descriptor) { | |
67 | this.descriptor = descriptor; | |
68 | } | |
69 | ||
70 | @Override | |
71 | public SynthesizedObject.Descriptor descriptor() { | |
72 |
1
1. descriptor : replaced return value with null for com/github/dakusui/osynth/core/InvocationController$Base::descriptor → KILLED |
return this.descriptor; |
73 | } | |
74 | } | |
75 | } | |
Mutations | ||
16 |
1.1 |
|
17 |
1.1 2.2 |
|
27 |
1.1 |
|
42 |
1.1 |
|
53 |
1.1 |
|
57 |
1.1 |
|
72 |
1.1 |