tmf: lttngControl: TraceEnablement: mi support + utility function
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng2.control.core / src / org / eclipse / linuxtools / internal / lttng2 / control / core / model / impl / EventInfo.java
1 /**********************************************************************
2 * Copyright (c) 2012, 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 * Bernd Hufmann - Initial API and implementation
11 **********************************************************************/
12 package org.eclipse.linuxtools.internal.lttng2.control.core.model.impl;
13
14 import org.eclipse.linuxtools.internal.lttng2.control.core.model.IEventInfo;
15 import org.eclipse.linuxtools.internal.lttng2.control.core.model.LogLevelType;
16 import org.eclipse.linuxtools.internal.lttng2.control.core.model.TraceEnablement;
17
18 /**
19 * <p>
20 * Implementation of the trace event interface (IEventInfo) to store event
21 * related data.
22 * </p>
23 *
24 * @author Bernd Hufmann
25 */
26 public class EventInfo extends BaseEventInfo implements IEventInfo {
27
28 // ------------------------------------------------------------------------
29 // Attributes
30 // ------------------------------------------------------------------------
31 /**
32 * The enable state of the event.
33 */
34 private TraceEnablement fState = TraceEnablement.DISABLED;
35 /**
36 * The log level type.
37 */
38 private LogLevelType fLogLevelType = LogLevelType.LOGLEVEL_NONE;
39
40 // ------------------------------------------------------------------------
41 // Constructors
42 // ------------------------------------------------------------------------
43 /**
44 * Constructor
45 * @param name - name of event
46 */
47 public EventInfo(String name) {
48 super(name);
49 }
50
51 /**
52 * Copy constructor
53 * @param other - the instance to copy
54 */
55 public EventInfo(EventInfo other) {
56 super(other);
57 fState = other.fState;
58 fLogLevelType = other.fLogLevelType;
59 }
60
61 // ------------------------------------------------------------------------
62 // Accessors
63 // ------------------------------------------------------------------------
64
65 @Override
66 public TraceEnablement getState() {
67 return fState;
68 }
69
70 @Override
71 public void setState(TraceEnablement state) {
72 fState = state;
73 }
74
75 @Override
76 public void setState(String stateName) {
77 fState = TraceEnablement.valueOfString(stateName);
78 }
79
80 @Override
81 public LogLevelType getLogLevelType() {
82 return fLogLevelType;
83 }
84
85 @Override
86 public void setLogLevelType(LogLevelType type) {
87 fLogLevelType = type;
88 }
89
90 @Override
91 public void setLogLevelType(String shortName) {
92 fLogLevelType = LogLevelType.valueOfString(shortName);
93 }
94
95
96 @Override
97 public int hashCode() {
98 final int prime = 31;
99 int result = super.hashCode();
100 result = prime * result + ((fState == null) ? 0 : (fState.ordinal() + 1));
101 result = prime * result + ((fLogLevelType == null) ? 0 : fLogLevelType.hashCode());
102 return result;
103 }
104
105 @Override
106 public boolean equals(Object obj) {
107 if (this == obj) {
108 return true;
109 }
110 if (!super.equals(obj)) {
111 return false;
112 }
113 if (getClass() != obj.getClass()) {
114 return false;
115 }
116 EventInfo other = (EventInfo) obj;
117 if (fState != other.fState) {
118 return false;
119 }
120 if (fLogLevelType != other.fLogLevelType) {
121 return false;
122 }
123 return true;
124 }
125
126 @SuppressWarnings("nls")
127 @Override
128 public String toString() {
129 StringBuffer output = new StringBuffer();
130 output.append("[EventInfo(");
131 output.append(super.toString());
132 output.append(",State=");
133 output.append(fState);
134 output.append(",levelType=");
135 output.append(fLogLevelType);
136 output.append(")]");
137 return output.toString();
138 }
139 }
This page took 0.032497 seconds and 5 git commands to generate.