First part of LTTng 2.0 support
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng.ui / src / org / eclipse / linuxtools / lttng / ui / views / control / model / impl / TraceInfo.java
1 /**********************************************************************
2 * Copyright (c) 2012 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 * Bernd Hufmann - Initial API and implementation
11 **********************************************************************/
12 package org.eclipse.linuxtools.lttng.ui.views.control.model.impl;
13
14 import org.eclipse.linuxtools.lttng.ui.views.control.model.ITraceInfo;
15
16 /**
17 * <b><u>TraceInfo</u></b>
18 * <p>
19 * Implementation of the base trace information interface (ITraceInfo) to
20 * store common data.
21 * </p>
22 */
23 public class TraceInfo implements ITraceInfo {
24
25 // ------------------------------------------------------------------------
26 // Attributes
27 // ------------------------------------------------------------------------
28 /**
29 * The name of the element.
30 */
31 private String fName = null;
32
33 // ------------------------------------------------------------------------
34 // Constructors
35 // ------------------------------------------------------------------------
36 /**
37 * Constructor
38 * @param name - name of trace element
39 */
40 public TraceInfo(String name) {
41 if (name == null) {
42 throw new IllegalArgumentException();
43 }
44 fName = name;
45 }
46
47 /**
48 * Copy constructor
49 * @param other - the instance to copy
50 */
51 public TraceInfo(TraceInfo other) {
52 if (other == null) {
53 throw new IllegalArgumentException();
54 } else {
55 fName = String.valueOf(other.fName);
56 }
57 }
58
59 // ------------------------------------------------------------------------
60 // Accessors
61 // ------------------------------------------------------------------------
62 /*
63 * (non-Javadoc)
64 * @see org.eclipse.linuxtools.lttng.ui.views.control.model.ITraceInfo#getName()
65 */
66 @Override
67 public String getName() {
68 return fName;
69 }
70
71 /*
72 * (non-Javadoc)
73 * @see org.eclipse.linuxtools.lttng.ui.views.control.model.ITraceInfo#setName(java.lang.String)
74 */
75 @Override
76 public void setName(String name) {
77 fName = name;
78 }
79
80 /*
81 * (non-Javadoc)
82 * @see java.lang.Object#hashCode()
83 */
84 @Override
85 public int hashCode() {
86 if (fName == null) {
87 return 17;
88 }
89 return fName.hashCode();
90 }
91
92 /*
93 * (non-Javadoc)
94 * @see java.lang.Object#equals(java.lang.Object)
95 */
96 @Override
97 public boolean equals(Object other) {
98 if (!(other instanceof TraceInfo)) {
99 return false;
100 }
101
102 TraceInfo otherInfo = (TraceInfo) other;
103 return fName.equals(otherInfo.fName);
104 }
105
106 /*
107 * (non-Javadoc)
108 * @see java.lang.Object#toString()
109 */
110 @SuppressWarnings("nls")
111 @Override
112 public String toString() {
113 StringBuffer output = new StringBuffer();
114 output.append("[TraceInfo(");
115 output.append("Name=");
116 output.append(getName());
117 output.append(")]");
118 return output.toString();
119 }
120 }
This page took 0.033238 seconds and 6 git commands to generate.