1 | package com.github.dakusui.actionunit.actions; | |
2 | ||
3 | import com.github.dakusui.actionunit.core.Context; | |
4 | ||
5 | public interface ContextVariable { | |
6 | /** | |
7 | * A name of the variable. | |
8 | * The string returned by this method is used only for printing an action tree. | |
9 | * To identify a variable, a string returned by {@link Contextful#internalVariableName()}. | |
10 | * | |
11 | * @return A human-readable variable name. | |
12 | */ | |
13 | String variableName(); | |
14 | ||
15 | /** | |
16 | * @return An internal context variable name. | |
17 | */ | |
18 | String internalVariableName(); | |
19 | ||
20 | default <T> T resolve(Context context) { | |
21 |
1
1. resolve : replaced return value with null for com/github/dakusui/actionunit/actions/ContextVariable::resolve → KILLED |
return context.valueOf(this.internalVariableName()); |
22 | } | |
23 | ||
24 | /** | |
25 | * @return Returns a global variable. | |
26 | */ | |
27 | static ContextVariable createGlobal(String variableName) { | |
28 |
1
1. createGlobal : replaced return value with null for com/github/dakusui/actionunit/actions/ContextVariable::createGlobal → KILLED |
return new ContextVariable() { |
29 | @Override | |
30 | public String variableName() { | |
31 |
1
1. variableName : replaced return value with "" for com/github/dakusui/actionunit/actions/ContextVariable$1::variableName → KILLED |
return variableName; |
32 | } | |
33 | ||
34 | @Override | |
35 | public String internalVariableName() { | |
36 |
1
1. internalVariableName : replaced return value with "" for com/github/dakusui/actionunit/actions/ContextVariable$1::internalVariableName → SURVIVED |
return "GLOBAL:" + variableName; |
37 | } | |
38 | ||
39 | @Override | |
40 | public String toString() { | |
41 |
1
1. toString : replaced return value with "" for com/github/dakusui/actionunit/actions/ContextVariable$1::toString → KILLED |
return variableName(); |
42 | } | |
43 | }; | |
44 | } | |
45 | } | |
Mutations | ||
21 |
1.1 |
|
28 |
1.1 |
|
31 |
1.1 |
|
36 |
1.1 |
|
41 |
1.1 |