1 | package com.hammurapi.eventbus.tests; |
2 | |
3 | import java.io.ObjectInputStream; |
4 | import java.util.List; |
5 | import java.util.Map; |
6 | |
7 | import com.hammurapi.extract.CompiledExtractorBase; |
8 | import com.hammurapi.extract.Extractor; |
9 | |
10 | // TODO - bind T, V, C. Predicate instead of Extractor if ... |
11 | @SuppressWarnings("unchecked") |
12 | class TemplateJavaExtractor<T, V, C> extends CompiledExtractorBase<T, V, C> { |
13 | |
14 | /** |
15 | * Class identity for comparison with other classes. |
16 | */ |
17 | private static final List<Object> IDENTITY; |
18 | |
19 | static { |
20 | try { |
21 | ObjectInputStream ois = new ObjectInputStream(TemplateJavaExtractor.class.getResourceAsStream("TemplateJavaExtractor.identity")); |
22 | try { |
23 | IDENTITY = (List<Object>) ois.readObject(); |
24 | } finally { |
25 | ois.close(); |
26 | } |
27 | } catch (Exception e) { |
28 | throw new ExceptionInInitializerError(e); |
29 | } |
30 | } |
31 | |
32 | TemplateJavaExtractor(int[] map) { |
33 | super(map, false, 0, 2); // TODO context dependency and parameter indices from template |
34 | } |
35 | |
36 | @Override |
37 | protected V extractInternal(C context, Map<C, Map<Extractor<T, ? super V, C>, ? super V>> cache, T... obj) { |
38 | String p1 = (String) obj[map==null ? 0 : map[0]]; // TODO - Cast only if needed, loop. |
39 | // TODO Auto-generated method stub |
40 | return null; // TODO - expression. |
41 | } |
42 | |
43 | @Override |
44 | protected List<Object> getIdentity() { |
45 | return IDENTITY; |
46 | } |
47 | |
48 | @Override |
49 | protected CompiledExtractorBase<T, V, C> newInstance(int[] map) { |
50 | return new TemplateJavaExtractor<T, V, C>(map); |
51 | } |
52 | |
53 | } |