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