Rename xxx.lttng to xxx.lttng.core
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf / src / org / eclipse / linuxtools / tmf / event / TmfEventSource.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>TmfEventSource</u></b>
17 * <p>
18 * The event source.
19 */
20 public class TmfEventSource implements Cloneable {
21
22 // ------------------------------------------------------------------------
23 // Attributes
24 // ------------------------------------------------------------------------
25
26 protected Object fSourceId;
27
28 // ------------------------------------------------------------------------
29 // Constructors
30 // ------------------------------------------------------------------------
31
32 /**
33 * The default constructor
34 */
35 public TmfEventSource() {
36 fSourceId = null;
37 }
38
39 /**
40 * @param sourceId
41 */
42 public TmfEventSource(Object sourceId) {
43 fSourceId = sourceId;
44 }
45
46 /**
47 * Copy constructor
48 * @param other
49 */
50 public TmfEventSource(TmfEventSource other) {
51 if (other == null)
52 throw new IllegalArgumentException();
53 TmfEventSource o = (TmfEventSource) other;
54 fSourceId = o.fSourceId;
55 }
56
57 // ------------------------------------------------------------------------
58 // Accessors
59 // ------------------------------------------------------------------------
60
61 /**
62 * @return
63 */
64 public Object getSourceId() {
65 return fSourceId;
66 }
67
68 // ------------------------------------------------------------------------
69 // Object
70 // ------------------------------------------------------------------------
71
72 @Override
73 public int hashCode() {
74 return (fSourceId != null) ? fSourceId.hashCode() : 0;
75 }
76
77 @Override
78 public boolean equals(Object other) {
79 if (!(other instanceof TmfEventSource))
80 return false;
81 TmfEventSource o = (TmfEventSource) other;
82 return fSourceId.equals(o.fSourceId);
83 }
84
85 @Override
86 @SuppressWarnings("nls")
87 public String toString() {
88 return "[TmfEventSource(" + ((fSourceId != null) ? fSourceId.toString() : "null") + ")]";
89 }
90
91 @Override
92 public TmfEventSource clone() {
93 TmfEventSource clone = null;
94 try {
95 clone = (TmfEventSource) super.clone();
96 clone.fSourceId = fSourceId;
97 }
98 catch (CloneNotSupportedException e) {
99 e.printStackTrace();
100 }
101 return clone;
102 }
103 }
This page took 0.035274 seconds and 5 git commands to generate.