1 /*******************************************************************************
2 * Copyright (c) 2009, 2013 Ericsson
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
10 * Francois Chouinard - Initial API and implementation
11 * Francois Chouinard - Updated as per TMF Event Model 1.0
12 *******************************************************************************/
14 package org
.eclipse
.linuxtools
.tmf
.core
.event
;
16 import java
.util
.Collection
;
17 import java
.util
.Collections
;
20 * A basic implementation of ITmfEventType.
23 * @author Francois Chouinard
28 public class TmfEventType
implements ITmfEventType
{
30 // ------------------------------------------------------------------------
32 // ------------------------------------------------------------------------
34 private final String fContext
;
35 private final String fTypeId
;
36 private final ITmfEventField fRootField
;
38 // ------------------------------------------------------------------------
40 // ------------------------------------------------------------------------
45 public TmfEventType() {
46 this(DEFAULT_CONTEXT_ID
, DEFAULT_TYPE_ID
, null);
52 * @param context the type context
53 * @param typeId the type name
54 * @param root the root field
56 public TmfEventType(final String context
, final String typeId
, final ITmfEventField root
) {
57 if (context
== null || typeId
== null) {
58 throw new IllegalArgumentException();
64 // Register to the event type manager
65 TmfEventTypeManager
.getInstance().add(context
, this);
71 * @param type the other type
73 public TmfEventType(final ITmfEventType type
) {
75 throw new IllegalArgumentException();
77 fContext
= type
.getContext();
78 fTypeId
= type
.getName();
79 fRootField
= type
.getRootField();
82 // ------------------------------------------------------------------------
84 // ------------------------------------------------------------------------
87 public String
getContext() {
92 public String
getName() {
97 public ITmfEventField
getRootField() {
105 public Collection
<String
> getFieldNames() {
106 return (fRootField
!= null) ? fRootField
.getFieldNames() : Collections
.EMPTY_SET
;
109 // ------------------------------------------------------------------------
111 // ------------------------------------------------------------------------
114 public int hashCode() {
115 final int prime
= 31;
117 result
= prime
* result
+ fContext
.hashCode();
118 result
= prime
* result
+ fTypeId
.hashCode();
123 public boolean equals(final Object obj
) {
130 if (!(obj
instanceof TmfEventType
)) {
133 final TmfEventType other
= (TmfEventType
) obj
;
134 if (!fContext
.equals(other
.fContext
)) {
137 if (!fTypeId
.equals(other
.fTypeId
)) {
144 @SuppressWarnings("nls")
145 public String
toString() {
146 return "TmfEventType [fContext=" + fContext
+ ", fTypeId=" + fTypeId
+ "]";