blob: cce3401801836649a113c3ffc5d5f5ed8a06514e [file] [log] [blame]
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -08001package net.floodlightcontroller.flowcache;
2
3import java.util.Arrays;
4
5import net.floodlightcontroller.devicemanager.IDevice;
6import net.floodlightcontroller.flowcache.IFlowCacheService.FCQueryEvType;
7
8
9/**
10 * The Class FCQueryObj.
11 */
12public class FCQueryObj {
13
14 /** The caller of the flow cache query. */
15 public IFlowQueryHandler fcQueryHandler;
16 /** The application instance name. */
17 public String applInstName;
18 /** The vlan Id. */
19 public Short[] vlans;
20 /** The destination device. */
21 public IDevice dstDevice;
22 /** The source device. */
23 public IDevice srcDevice;
24 /** The caller name */
25 public String callerName;
26 /** Event type that triggered this flow query submission */
27 public FCQueryEvType evType;
28 /** The caller opaque data. Returned unchanged in the query response
29 * via the callback. The type of this object could be different for
30 * different callers */
31 public Object callerOpaqueObj;
32
33 /**
34 * Instantiates a new flow cache query object
35 */
36 public FCQueryObj(IFlowQueryHandler fcQueryHandler,
37 String applInstName,
38 Short vlan,
39 IDevice srcDevice,
40 IDevice dstDevice,
41 String callerName,
42 FCQueryEvType evType,
43 Object callerOpaqueObj) {
44 this.fcQueryHandler = fcQueryHandler;
45 this.applInstName = applInstName;
46 this.srcDevice = srcDevice;
47 this.dstDevice = dstDevice;
48 this.callerName = callerName;
49 this.evType = evType;
50 this.callerOpaqueObj = callerOpaqueObj;
51
52 if (vlan != null) {
53 this.vlans = new Short[] { vlan };
54 } else {
55 if (srcDevice != null) {
56 this.vlans = srcDevice.getVlanId();
57 } else if (dstDevice != null) {
58 this.vlans = dstDevice.getVlanId();
59 }
60 }
61 }
62
63 @Override
64 public String toString() {
65 return "FCQueryObj [fcQueryCaller=" + fcQueryHandler
66 + ", applInstName="
67 + applInstName + ", vlans=" + Arrays.toString(vlans)
68 + ", dstDevice=" + dstDevice + ", srcDevice="
69 + srcDevice + ", callerName=" + callerName + ", evType="
70 + evType + ", callerOpaqueObj=" + callerOpaqueObj + "]";
71 }
72
73 @Override
74 public boolean equals(Object obj) {
75 if (this == obj)
76 return true;
77 if (obj == null)
78 return false;
79 if (getClass() != obj.getClass())
80 return false;
81 FCQueryObj other = (FCQueryObj) obj;
82 if (applInstName == null) {
83 if (other.applInstName != null)
84 return false;
85 } else if (!applInstName.equals(other.applInstName))
86 return false;
87 if (callerName == null) {
88 if (other.callerName != null)
89 return false;
90 } else if (!callerName.equals(other.callerName))
91 return false;
92 if (callerOpaqueObj == null) {
93 if (other.callerOpaqueObj != null)
94 return false;
95 } else if (!callerOpaqueObj.equals(other.callerOpaqueObj))
96 return false;
97 if (dstDevice == null) {
98 if (other.dstDevice != null)
99 return false;
100 } else if (!dstDevice.equals(other.dstDevice))
101 return false;
102 if (evType != other.evType)
103 return false;
104 if (fcQueryHandler != other.fcQueryHandler)
105 return false;
106 if (srcDevice == null) {
107 if (other.srcDevice != null)
108 return false;
109 } else if (!srcDevice.equals(other.srcDevice))
110 return false;
111 if (!Arrays.equals(vlans, other.vlans))
112 return false;
113 return true;
114 }
115
116
117}