gdbtrace: Move plugins to the Trace Compass namespace
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng2.control.core / src / org / eclipse / linuxtools / internal / lttng2 / control / core / model / TraceEnablement.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 * Jonathan Rajotte - Machine interface support and utility function
12 **********************************************************************/
13 package org.eclipse.linuxtools.internal.lttng2.control.core.model;
14
15 import java.security.InvalidParameterException;
16
17 /**
18 * Enumeration for enabled/disabled states.
19 *
20 * @author Bernd Hufmann
21 */
22 public enum TraceEnablement {
23
24 // ------------------------------------------------------------------------
25 // Enum definition
26 // ------------------------------------------------------------------------
27 /** Tracing is disabled */
28 DISABLED("disabled", "false"), //$NON-NLS-1$ //$NON-NLS-2$
29 /** Tracing is enabled */
30 ENABLED("enabled", "true"); //$NON-NLS-1$ //$NON-NLS-2$
31
32 // ------------------------------------------------------------------------
33 // Attributes
34 // ------------------------------------------------------------------------
35 /**
36 * Name of enum
37 */
38 private final String fInName;
39 private final String fInMiName;
40
41 // ------------------------------------------------------------------------
42 // Constuctors
43 // ------------------------------------------------------------------------
44
45 /**
46 * Private constructor
47 *
48 * @param name
49 * the name of state
50 */
51 private TraceEnablement(String name, String miName) {
52 fInName = name;
53 fInMiName = miName;
54 }
55
56 // ------------------------------------------------------------------------
57 // Accessors
58 // ------------------------------------------------------------------------
59 /**
60 * @return state name
61 */
62 public String getInName() {
63 return fInName;
64 }
65
66 /**
67 * @return state name
68 */
69 public String getInMiName() {
70 return fInMiName;
71 }
72
73 /**
74 * @param name
75 * name of the desired enum
76 * @return the corresponding {@link TraceEnablement} matching name
77 */
78 public static TraceEnablement valueOfString(String name) {
79 if (name == null) {
80 throw new InvalidParameterException();
81 }
82 for (TraceEnablement enablementType : TraceEnablement.values()) {
83 boolean exist = enablementType.fInName.equalsIgnoreCase(name) || enablementType.fInMiName.equalsIgnoreCase(name);
84 if (exist) {
85 return enablementType;
86 }
87 }
88 return DISABLED;
89 }
90
91 }
This page took 0.051332 seconds and 6 git commands to generate.