tmf: Fix the actual end time of state system modules
[deliverable/tracecompass.git] / tmf / org.eclipse.tracecompass.tmf.core / src / org / eclipse / tracecompass / tmf / core / event / TmfEventType.java
1 /*******************************************************************************
2 * Copyright (c) 2009, 2014 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 * Francois Chouinard - Updated as per TMF Event Model 1.0
12 *******************************************************************************/
13
14 package org.eclipse.tracecompass.tmf.core.event;
15
16 import java.util.Collection;
17 import java.util.Collections;
18
19 import org.eclipse.jdt.annotation.NonNull;
20
21 /**
22 * A basic implementation of ITmfEventType.
23 *
24 * @version 1.0
25 * @author Francois Chouinard
26 *
27 * @see ITmfEvent
28 * @see ITmfEventField
29 */
30 public class TmfEventType implements ITmfEventType {
31
32 // ------------------------------------------------------------------------
33 // Attributes
34 // ------------------------------------------------------------------------
35
36 private final @NonNull String fTypeId;
37 private final ITmfEventField fRootField;
38
39 // ------------------------------------------------------------------------
40 // Constructors
41 // ------------------------------------------------------------------------
42
43 /**
44 * Default constructor
45 */
46 public TmfEventType() {
47 this(DEFAULT_TYPE_ID, null);
48 }
49
50 /**
51 * Full constructor
52 *
53 * @param typeId the type name
54 * @param root the root field
55 */
56 public TmfEventType(final @NonNull String typeId, final ITmfEventField root) {
57 fTypeId = typeId;
58 fRootField = root;
59 }
60
61 /**
62 * Copy constructor
63 *
64 * @param type the other type
65 */
66 public TmfEventType(@NonNull ITmfEventType type) {
67 fTypeId = type.getName();
68 fRootField = type.getRootField();
69 }
70
71 // ------------------------------------------------------------------------
72 // ITmfEventType
73 // ------------------------------------------------------------------------
74
75 @Override
76 public String getName() {
77 return fTypeId;
78 }
79
80 @Override
81 public ITmfEventField getRootField() {
82 return fRootField;
83 }
84
85 @Override
86 public Collection<String> getFieldNames() {
87 return (fRootField != null) ? fRootField.getFieldNames() : Collections.EMPTY_SET;
88 }
89
90 // ------------------------------------------------------------------------
91 // Object
92 // ------------------------------------------------------------------------
93
94 @Override
95 public int hashCode() {
96 final int prime = 31;
97 int result = 1;
98 result = prime * result + fTypeId.hashCode();
99 return result;
100 }
101
102 @Override
103 public boolean equals(final Object obj) {
104 if (this == obj) {
105 return true;
106 }
107 if (obj == null) {
108 return false;
109 }
110 if (!(obj instanceof TmfEventType)) {
111 return false;
112 }
113 final TmfEventType other = (TmfEventType) obj;
114 if (!fTypeId.equals(other.fTypeId)) {
115 return false;
116 }
117 return true;
118 }
119
120 @Override
121 @SuppressWarnings("nls")
122 public String toString() {
123 return "TmfEventType [fTypeId=" + fTypeId + "]";
124 }
125
126 }
This page took 0.033382 seconds and 5 git commands to generate.