Package: TraceUtil

TraceUtil

nameinstructionbranchcomplexitylinemethod
TraceUtil()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
readState(Class, Class)
M: 38 C: 0
0%
M: 4 C: 0
0%
M: 3 C: 0
0%
M: 9 C: 0
0%
M: 1 C: 0
0%

Coverage

1: package org.overture.codegen.runtime.traces;
2:
3: import java.lang.reflect.Field;
4:
5: public class TraceUtil
6: {
7:         public static <T> T readState(Class<?> module, Class<T> stateType)
8:         {
9:                 Field[] fields = module.getDeclaredFields();
10:
11:•                for (Field f : fields)
12:                 {
13:•                        if (!ModuleCopy.isFinal(f))
14:                         {
15:                                 // It' the state component
16:                                 f.setAccessible(true);
17:                                 try
18:                                 {
19:                                         Object stateVal = f.get(null);
20:                                         return stateType.cast(stateVal);
21:                                 } catch (IllegalArgumentException | IllegalAccessException e)
22:                                 {
23:                                         e.printStackTrace();
24:                                 }
25:                         }
26:                 }
27:
28:                 return null;
29:         }
30: }