1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.mobility.bus.service.util;
17
18 import java.util.ArrayList;
19 import java.util.List;
20
21 import org.apache.commons.collections.CollectionUtils;
22 import org.apache.commons.collections.Transformer;
23 import org.kuali.mobility.bus.entity.BusRoute;
24 import org.kuali.mobility.bus.entity.BusRouteImpl;
25 import org.kuali.mobility.bus.entity.BusStop;
26 import org.kuali.mobility.bus.entity.BusStopImpl;
27
28
29
30
31
32 public class BusRouteTransform implements Transformer {
33
34 @Override
35 public BusRouteImpl transform( Object obj ) {
36 BusRouteImpl proxy = null;
37
38 if( obj instanceof BusRoute ) {
39 proxy = new BusRouteImpl();
40 proxy.setId(((BusRoute)obj).getId());
41 proxy.setColor(((BusRoute)obj).getColor());
42 proxy.setName(((BusRoute)obj).getName());
43 proxy.setPath(((BusRoute)obj).getPath());
44
45 List<BusStopImpl> stops = new ArrayList<BusStopImpl>();
46 CollectionUtils.collect( ((BusRoute)obj).getStops(), new BusStopTransform(), stops );
47 proxy.setStops(stops);
48 }
49
50 return proxy;
51 }
52
53 }