| 1 | package de.uka.ipd.sdq.probespec.framework; |
| 2 | |
| 3 | /** |
| 4 | * Represents a (ProbeSet, {@link RequestContext})-pair. The ProbeSet is |
| 5 | * identified by its ID. |
| 6 | * <p> |
| 7 | * It is used to uniquely identify {@link ProbeSetSample}. |
| 8 | * |
| 9 | * @author Faber |
| 10 | * @author Philipp Merkle |
| 11 | * |
| 12 | */ |
| 13 | public class ProbeSetAndRequestContext { |
| 14 | |
| 15 | // the ID representing the ProbeSet |
| 16 | private Integer probeSetId; |
| 17 | |
| 18 | private RequestContext requestContext; |
| 19 | |
| 20 | /** |
| 21 | * Default constructor. Constructs a pair consisting of a ProbeSet and a |
| 22 | * {@link RequestContext}. |
| 23 | * |
| 24 | * @param probeSetId |
| 25 | * the ID representing the ProbeSet |
| 26 | * @param requestContext |
| 27 | * the RequestContext |
| 28 | */ |
| 29 | public ProbeSetAndRequestContext(Integer probeSetId, |
| 30 | RequestContext requestContext) { |
| 31 | this.probeSetId = probeSetId; |
| 32 | this.requestContext = requestContext; |
| 33 | } |
| 34 | |
| 35 | /** |
| 36 | * Returns the ID of the ProbeSet component. |
| 37 | * |
| 38 | * @return The ID representing the ProbeSet |
| 39 | */ |
| 40 | public Integer getProbeSetID() { |
| 41 | return probeSetId; |
| 42 | } |
| 43 | |
| 44 | /** |
| 45 | * Returns the {@link RequestContext} component. |
| 46 | * |
| 47 | * @return the context |
| 48 | */ |
| 49 | public RequestContext getCtxID() { |
| 50 | return requestContext; |
| 51 | } |
| 52 | |
| 53 | @Override |
| 54 | public int hashCode() { |
| 55 | final int prime = 31; |
| 56 | int result = 1; |
| 57 | result = prime * result |
| 58 | + ((requestContext == null) ? 0 : requestContext.hashCode()); |
| 59 | result = prime * result |
| 60 | + ((probeSetId == null) ? 0 : probeSetId.hashCode()); |
| 61 | return result; |
| 62 | } |
| 63 | |
| 64 | @Override |
| 65 | public boolean equals(Object obj) { |
| 66 | if (this == obj) { |
| 67 | return true; |
| 68 | } |
| 69 | if (obj == null) { |
| 70 | return false; |
| 71 | } |
| 72 | if (!(obj instanceof ProbeSetAndRequestContext)) { |
| 73 | return false; |
| 74 | } |
| 75 | ProbeSetAndRequestContext other = (ProbeSetAndRequestContext) obj; |
| 76 | if (requestContext == null) { |
| 77 | if (other.requestContext != null) { |
| 78 | return false; |
| 79 | } |
| 80 | } else if (!requestContext.equals(other.requestContext)) { |
| 81 | return false; |
| 82 | } |
| 83 | if (probeSetId == null) { |
| 84 | if (other.probeSetId != null) { |
| 85 | return false; |
| 86 | } |
| 87 | } else if (!probeSetId.equals(other.probeSetId)) { |
| 88 | return false; |
| 89 | } |
| 90 | return true; |
| 91 | } |
| 92 | |
| 93 | @Override |
| 94 | public String toString() { |
| 95 | return probeSetId + "-" + requestContext.toString(); |
| 96 | } |
| 97 | |
| 98 | } |