Commit | Line | Data |
---|---|---|
8c8bf09f ASL |
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: | |
1f506a43 | 10 | * Francois Chouinard - Initial API and implementation |
8c8bf09f ASL |
11 | *******************************************************************************/ |
12 | ||
13 | package org.eclipse.linuxtools.tmf.event; | |
14 | ||
15 | /** | |
16 | * <b><u>TmfEventSource</u></b> | |
17 | * <p> | |
18 | * The event source. | |
19 | */ | |
1a971e96 | 20 | public class TmfEventSource implements Cloneable { |
8c8bf09f | 21 | |
cbd4ad82 | 22 | // ------------------------------------------------------------------------ |
8c8bf09f | 23 | // Attributes |
cbd4ad82 | 24 | // ------------------------------------------------------------------------ |
8c8bf09f | 25 | |
28b94d61 | 26 | protected Object fSourceId; |
8c8bf09f | 27 | |
cbd4ad82 | 28 | // ------------------------------------------------------------------------ |
8c8bf09f | 29 | // Constructors |
cbd4ad82 | 30 | // ------------------------------------------------------------------------ |
8c8bf09f ASL |
31 | |
32 | /** | |
cbd4ad82 | 33 | * The default constructor |
8c8bf09f ASL |
34 | */ |
35 | public TmfEventSource() { | |
cbd4ad82 | 36 | fSourceId = null; |
8c8bf09f ASL |
37 | } |
38 | ||
39 | /** | |
40 | * @param sourceId | |
41 | */ | |
42 | public TmfEventSource(Object sourceId) { | |
43 | fSourceId = sourceId; | |
44 | } | |
45 | ||
28b94d61 | 46 | /** |
cbd4ad82 | 47 | * Copy constructor |
28b94d61 FC |
48 | * @param other |
49 | */ | |
50 | public TmfEventSource(TmfEventSource other) { | |
cbd4ad82 FC |
51 | if (other == null) |
52 | throw new IllegalArgumentException(); | |
53 | TmfEventSource o = (TmfEventSource) other; | |
54 | fSourceId = o.fSourceId; | |
28b94d61 FC |
55 | } |
56 | ||
cbd4ad82 | 57 | // ------------------------------------------------------------------------ |
8c8bf09f | 58 | // Accessors |
cbd4ad82 | 59 | // ------------------------------------------------------------------------ |
8c8bf09f ASL |
60 | |
61 | /** | |
62 | * @return | |
63 | */ | |
64 | public Object getSourceId() { | |
65 | return fSourceId; | |
66 | } | |
1f506a43 | 67 | |
cbd4ad82 FC |
68 | // ------------------------------------------------------------------------ |
69 | // Object | |
70 | // ------------------------------------------------------------------------ | |
1f506a43 | 71 | |
28b94d61 | 72 | @Override |
cbd4ad82 FC |
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 | } | |
28b94d61 FC |
84 | |
85 | @Override | |
1f506a43 | 86 | public String toString() { |
28b94d61 | 87 | return "[TmfEventSource(" + ((fSourceId != null) ? fSourceId.toString() : "null") + ")]"; |
1f506a43 FC |
88 | } |
89 | ||
1a971e96 FC |
90 | @Override |
91 | public TmfEventSource clone() { | |
92 | TmfEventSource clone = null; | |
93 | try { | |
94 | clone = (TmfEventSource) super.clone(); | |
95 | clone.fSourceId = null; | |
96 | } | |
97 | catch (CloneNotSupportedException e) { | |
98 | e.printStackTrace(); | |
99 | } | |
100 | return clone; | |
101 | } | |
8c8bf09f | 102 | } |