2010-10-15 Francois Chouinard <fchouinard@gmail.com> Fix for Bug327910
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf / src / org / eclipse / linuxtools / tmf / event / TmfEventReference.java
1 /*******************************************************************************
2 * Copyright (c) 2009 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 * Francois Chouinard - Initial API and implementation
11 *******************************************************************************/
12
13 package org.eclipse.linuxtools.tmf.event;
14
15 /**
16 * <b><u>TmfEventReference</u></b>
17 * <p>
18 * An application-defined event reference.
19 */
20 public class TmfEventReference implements Cloneable {
21
22 // ------------------------------------------------------------------------
23 // Attributes
24 // ------------------------------------------------------------------------
25
26 protected Object fReference;
27
28 // ------------------------------------------------------------------------
29 // Constructors
30 // ------------------------------------------------------------------------
31
32 /**
33 * The default constructor
34 */
35 public TmfEventReference() {
36 fReference = null;
37 }
38
39 /**
40 * @param reference the event reference
41 */
42 public TmfEventReference(Object reference) {
43 fReference = reference;
44 }
45
46 /**
47 * Copy constructor
48 * @param other the original event reference
49 */
50 public TmfEventReference(TmfEventReference other) {
51 if (other == null)
52 throw new IllegalArgumentException();
53 TmfEventReference o = (TmfEventReference) other;
54 fReference = o.fReference;
55 }
56
57 // ------------------------------------------------------------------------
58 // Accessors
59 // ------------------------------------------------------------------------
60
61 /**
62 * @return the event reference
63 */
64 public Object getReference() {
65 return fReference;
66 }
67
68 // ------------------------------------------------------------------------
69 // Object
70 // ------------------------------------------------------------------------
71
72 @Override
73 public int hashCode() {
74 return (fReference != null) ? fReference.hashCode() : 0;
75 }
76
77 @Override
78 public String toString() {
79 return "[TmfEventReference(" + ((fReference != null) ? fReference.toString() : "null") + ")]";
80 }
81
82 @Override
83 public boolean equals(Object other) {
84 if (!(other instanceof TmfEventReference))
85 return false;
86 TmfEventReference o = (TmfEventReference) other;
87 return fReference.equals(o.fReference);
88 }
89
90 @Override
91 public TmfEventReference clone() {
92 TmfEventReference clone = null;
93 try {
94 clone = (TmfEventReference) super.clone();
95 clone.fReference = null;
96 }
97 catch (CloneNotSupportedException e) {
98 e.printStackTrace();
99 }
100 return clone;
101 }
102 }
This page took 0.034652 seconds and 5 git commands to generate.