1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.rblasch.convert;
17
18 import org.rblasch.convert.converters.lang.CastConverter;
19 import org.rblasch.convert.converters.lang.IdentityConverter;
20 import org.rblasch.convert.converters.lang.ObjectToStringConverter;
21 import org.rblasch.convert.graph.Graph;
22 import org.rblasch.convert.graph.SparseWeightedDirectedGraph;
23 import org.rblasch.convert.graph.WeightedDirectedGraph;
24 import org.rblasch.convert.type.ClassType;
25 import org.rblasch.convert.type.ParameterizableType;
26 import org.rblasch.convert.type.Type;
27
28 import java.util.Arrays;
29 import java.util.Iterator;
30
31 /***
32 * @author Ronald Blaschke
33 * @deprecated no longer used
34 */
35 public class JlGraphFactory {
36 private static void addConnection(final Graph g, final MetaConverter mc) {
37 g.addConnection(new TypeVertex(mc.getSourceType()),
38 new ConverterEdge(mc, mc.getWeight()),
39 new TypeVertex(mc.getDestinationType()));
40 }
41
42 public static WeightedDirectedGraph createGraphFor(final Type t) {
43 final WeightedDirectedGraph g = new SparseWeightedDirectedGraph();
44
45
46 addConnection(g, new IdentityConverter(t));
47
48
49 if (t instanceof ClassType) {
50 final ClassType ct = (ClassType) t;
51
52 Class tmp = ct.getTheClass();
53 while (tmp.getSuperclass() != null) {
54 addConnection(g, new CastConverter(tmp, tmp.getSuperclass()));
55
56 for (final Iterator i = Arrays.asList(tmp.getInterfaces()).iterator(); i.hasNext();) {
57 final Class iface = (Class) i.next();
58 addConnection(g, new CastConverter(tmp, iface));
59 }
60
61 tmp = tmp.getSuperclass();
62 }
63 } else if (t instanceof ParameterizableType) {
64
65 }
66
67
68 addConnection(g, new ObjectToStringConverter());
69
70 return g;
71 }
72 }