8662c76e3061aed046e549a279c676c87246053a
[deliverable/tracecompass.git] / org.eclipse.linuxtools.pcap.core / src / org / eclipse / linuxtools / internal / pcap / core / protocol / pcap / PcapEndpoint.java
1 /*******************************************************************************
2 * Copyright (c) 2014 Ericsson
3 *
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
8 *
9 * Contributors:
10 * Vincent Perot - Initial API and implementation
11 *******************************************************************************/
12
13 package org.eclipse.linuxtools.internal.pcap.core.protocol.pcap;
14
15 import org.eclipse.jdt.annotation.Nullable;
16 import org.eclipse.linuxtools.internal.pcap.core.endpoint.ProtocolEndpoint;
17
18 /**
19 * Class that extends the {@link ProtocolEndpoint} class. It represents the endpoint at
20 * a Pcap level.
21 *
22 * @author Vincent Perot
23 */
24 public class PcapEndpoint extends ProtocolEndpoint {
25
26 /**
27 * Constructor of the {@link PcapEndpoint} class. It takes a packet to get
28 * its endpoint. Since every packet has two endpoints (source and
29 * destination), the isSourceEndpoint parameter is used to specify which
30 * endpoint to take.
31 *
32 * @param packet
33 * The packet that contains the endpoints.
34 * @param isSourceEndpoint
35 * Whether to take the source or the destination endpoint of the
36 * packet.
37 */
38 public PcapEndpoint(PcapPacket packet, boolean isSourceEndpoint) {
39 super(packet, isSourceEndpoint);
40 }
41
42 @Override
43 public int hashCode() {
44 return 0;
45 }
46
47 @Override
48 public String toString() {
49 return EMPTY_STRING;
50 }
51
52 @Override
53 public boolean equals(@Nullable Object obj) {
54 if (this == obj) {
55 return true;
56 }
57 if (!(obj instanceof PcapEndpoint)) {
58 return false;
59 }
60
61 PcapEndpoint other = (PcapEndpoint) obj;
62
63 // Check above layers.
64 ProtocolEndpoint endpoint = getParentEndpoint();
65 if (endpoint != null) {
66 return endpoint.equals(other.getParentEndpoint());
67 }
68 return true;
69 }
70
71 }
This page took 0.061175 seconds and 4 git commands to generate.