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
CommitLineData
eb1bab5b 1/**********************************************************************
54f2dcc0 2 * Copyright (c) 2012, 2014 Ericsson
11252342 3 *
eb1bab5b
BH
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
11252342
AM
8 *
9 * Contributors:
eb1bab5b
BH
10 * Bernd Hufmann - Initial API and implementation
11 **********************************************************************/
8e8c0226 12package org.eclipse.linuxtools.internal.lttng2.control.core.model.impl;
eb1bab5b 13
8e8c0226 14import org.eclipse.linuxtools.internal.lttng2.control.core.model.IEventInfo;
54f2dcc0 15import org.eclipse.linuxtools.internal.lttng2.control.core.model.LogLevelType;
8e8c0226 16import org.eclipse.linuxtools.internal.lttng2.control.core.model.TraceEnablement;
eb1bab5b
BH
17
18/**
eb1bab5b
BH
19* <p>
20* Implementation of the trace event interface (IEventInfo) to store event
11252342 21* related data.
eb1bab5b 22* </p>
11252342 23*
dbd4432d 24* @author Bernd Hufmann
eb1bab5b
BH
25*/
26public 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;
54f2dcc0
BH
35 /**
36 * The log level type.
37 */
38 private LogLevelType fLogLevelType = LogLevelType.LOGLEVEL_NONE;
11252342 39
eb1bab5b
BH
40 // ------------------------------------------------------------------------
41 // Constructors
42 // ------------------------------------------------------------------------
43 /**
44 * Constructor
45 * @param name - name of event
46 */
47 public EventInfo(String name) {
48 super(name);
49 }
11252342 50
eb1bab5b
BH
51 /**
52 * Copy constructor
53 * @param other - the instance to copy
54 */
55 public EventInfo(EventInfo other) {
56 super(other);
57 fState = other.fState;
54f2dcc0 58 fLogLevelType = other.fLogLevelType;
eb1bab5b 59 }
11252342 60
eb1bab5b
BH
61 // ------------------------------------------------------------------------
62 // Accessors
63 // ------------------------------------------------------------------------
11252342 64
eb1bab5b
BH
65 @Override
66 public TraceEnablement getState() {
67 return fState;
68 }
69
eb1bab5b
BH
70 @Override
71 public void setState(TraceEnablement state) {
72 fState = state;
73 }
74
eb1bab5b
BH
75 @Override
76 public void setState(String stateName) {
4e94d876 77 fState = TraceEnablement.valueOfString(stateName);
eb1bab5b
BH
78 }
79
54f2dcc0
BH
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) {
927bc9a3 92 fLogLevelType = LogLevelType.valueOfString(shortName);
54f2dcc0
BH
93 }
94
95
eb1bab5b
BH
96 @Override
97 public int hashCode() {
d132bcc7
BH
98 final int prime = 31;
99 int result = super.hashCode();
100 result = prime * result + ((fState == null) ? 0 : (fState.ordinal() + 1));
54f2dcc0 101 result = prime * result + ((fLogLevelType == null) ? 0 : fLogLevelType.hashCode());
eb1bab5b
BH
102 return result;
103 }
104
eb1bab5b 105 @Override
d132bcc7
BH
106 public boolean equals(Object obj) {
107 if (this == obj) {
108 return true;
109 }
110 if (!super.equals(obj)) {
eb1bab5b
BH
111 return false;
112 }
d132bcc7 113 if (getClass() != obj.getClass()) {
eb1bab5b
BH
114 return false;
115 }
d132bcc7
BH
116 EventInfo other = (EventInfo) obj;
117 if (fState != other.fState) {
eb1bab5b
BH
118 return false;
119 }
54f2dcc0
BH
120 if (fLogLevelType != other.fLogLevelType) {
121 return false;
122 }
eb1bab5b
BH
123 return true;
124 }
d132bcc7 125
eb1bab5b
BH
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);
54f2dcc0
BH
134 output.append(",levelType=");
135 output.append(fLogLevelType);
eb1bab5b
BH
136 output.append(")]");
137 return output.toString();
138 }
139}
This page took 0.055919 seconds and 5 git commands to generate.