Commit | Line | Data |
---|---|---|
d4514365 | 1 | /********************************************************************** |
94cce698 | 2 | * Copyright (c) 2012, 2013 Ericsson |
d4514365 BH |
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 | **********************************************************************/ | |
8e8c0226 | 12 | package org.eclipse.linuxtools.internal.lttng2.control.core.model.impl; |
d4514365 | 13 | |
8e8c0226 | 14 | import org.eclipse.linuxtools.internal.lttng2.control.core.model.IFieldInfo; |
d4514365 BH |
15 | |
16 | /** | |
17 | * <p> | |
18 | * Implementation of the basic trace event interface (IEventInfo) to store event | |
19 | * related data. | |
20 | * </p> | |
21 | * | |
22 | * @author Bernd Hufmann | |
23 | */ | |
24 | public class FieldInfo extends TraceInfo implements IFieldInfo { | |
25 | ||
26 | // ------------------------------------------------------------------------ | |
27 | // Attributes | |
28 | // ------------------------------------------------------------------------ | |
29 | /** | |
30 | * The trace event type. | |
31 | */ | |
32 | private String fFieldType; | |
33 | ||
34 | // ------------------------------------------------------------------------ | |
35 | // Constructors | |
36 | // ------------------------------------------------------------------------ | |
37 | /** | |
38 | * Constructor | |
39 | * @param name - name of base event | |
40 | */ | |
41 | public FieldInfo(String name) { | |
42 | super(name); | |
43 | } | |
44 | ||
45 | /** | |
46 | * Copy constructor | |
47 | * @param other - the instance to copy | |
48 | */ | |
49 | public FieldInfo(FieldInfo other) { | |
50 | super(other); | |
51 | fFieldType = other.fFieldType; | |
52 | } | |
53 | ||
54 | // ------------------------------------------------------------------------ | |
55 | // Accessors | |
56 | // ------------------------------------------------------------------------ | |
57 | ||
d4514365 BH |
58 | @Override |
59 | public String getFieldType() { | |
60 | return fFieldType; | |
61 | } | |
62 | ||
d4514365 BH |
63 | @Override |
64 | public void setFieldType(String fieldType) { | |
e5e5b3db | 65 | fFieldType = fieldType.toLowerCase(); |
d4514365 BH |
66 | } |
67 | ||
d4514365 BH |
68 | @Override |
69 | public int hashCode() { | |
70 | final int prime = 31; | |
71 | int result = super.hashCode(); | |
72 | result = prime * result | |
73 | + ((fFieldType == null) ? 0 : fFieldType.hashCode()); | |
74 | return result; | |
75 | } | |
76 | ||
d4514365 BH |
77 | @Override |
78 | public boolean equals(Object obj) { | |
79 | if (this == obj) { | |
80 | return true; | |
81 | } | |
82 | if (!super.equals(obj)) { | |
83 | return false; | |
84 | } | |
85 | if (getClass() != obj.getClass()) { | |
86 | return false; | |
87 | } | |
88 | FieldInfo other = (FieldInfo) obj; | |
89 | if (fFieldType == null) { | |
90 | if (other.fFieldType != null) { | |
91 | return false; | |
92 | } | |
93 | } else if (!fFieldType.equals(other.fFieldType)) { | |
94 | return false; | |
95 | } | |
96 | return true; | |
97 | } | |
98 | ||
d4514365 BH |
99 | @SuppressWarnings("nls") |
100 | @Override | |
101 | public String toString() { | |
102 | StringBuffer output = new StringBuffer(); | |
103 | output.append("[FieldInfo("); | |
104 | output.append(super.toString()); | |
105 | output.append(",type="); | |
106 | output.append(fFieldType); | |
107 | return output.toString(); | |
108 | } | |
109 | } |