1 /*******************************************************************************
2 * Copyright (c) 2014 Ericsson
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
10 * Vincent Perot - Initial API and implementation
11 *******************************************************************************/
13 package org
.eclipse
.linuxtools
.pcap
.core
.endpoint
;
15 import org
.eclipse
.jdt
.annotation
.Nullable
;
16 import org
.eclipse
.linuxtools
.pcap
.core
.packet
.Packet
;
19 * Class that represents a pair of endpoints. This is used to find a packet
20 * stream between to endpoints.
22 * @author Vincent Perot
24 public class ProtocolEndpointPair
{
26 private final ProtocolEndpoint fEndpointA
;
27 private final ProtocolEndpoint fEndpointB
;
30 * Constructor of the class {@link ProtocolEndpointPair}. It constructs a
31 * {@link ProtocolEndpointPair} object from a packet.
34 * The packet that contains the endpoints.
36 public ProtocolEndpointPair(Packet packet
) {
37 fEndpointA
= packet
.getSourceEndpoint();
38 fEndpointB
= packet
.getDestinationEndpoint();
42 * Getter method that returns the first endpoint of the pair.
44 * @return The first endpoint.
46 public ProtocolEndpoint
getFirstEndpoint() {
51 * Getter method that returns the second endpoint of the pair.
53 * @return The second endpoint.
55 public ProtocolEndpoint
getSecondEndpoint() {
60 * Constructor of the class {@link ProtocolEndpointPair}. It constructs a
61 * {@link ProtocolEndpointPair} object from two endpoints.
66 * The second endpoint.
68 public ProtocolEndpointPair(ProtocolEndpoint endpointA
, ProtocolEndpoint endpointB
) {
69 fEndpointA
= endpointA
;
70 fEndpointB
= endpointB
;
74 public int hashCode() {
77 result
= prime
* result
+ fEndpointA
.hashCode() * fEndpointB
.hashCode();
82 public boolean equals(@Nullable Object obj
) {
87 if (!(obj
instanceof ProtocolEndpointPair
)) {
90 ProtocolEndpointPair other
= (ProtocolEndpointPair
) obj
;
92 return (this.fEndpointA
.equals(other
.fEndpointA
) && this.fEndpointB
.equals(other
.fEndpointB
)) ||
93 (this.fEndpointA
.equals(other
.fEndpointB
) && this.fEndpointB
.equals(other
.fEndpointA
));