Commit | Line | Data |
---|---|---|
5d10d135 ASL |
1 | /******************************************************************************* |
2 | * Copyright (c) 2009 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 | * Alvaro Sanchez-Leon (alvsan09@gmail.com) - Initial API and implementation | |
11 | *******************************************************************************/ | |
12 | package org.eclipse.linuxtools.lttng.state.model; | |
13 | ||
14 | ||
15 | ||
16 | /** | |
17 | * <b><u>LttvTrapState</u></b> | |
18 | * <p> | |
19 | * | |
20 | */ | |
21 | public class LttngTrapState implements Cloneable { | |
22 | // ======================================================================== | |
23 | // Data | |
24 | // ======================================================================= | |
25 | private Long running; | |
e31e01e8 | 26 | |
5d10d135 ASL |
27 | |
28 | // ======================================================================== | |
29 | // Constructor | |
30 | // ======================================================================= | |
e31e01e8 FC |
31 | |
32 | public LttngTrapState() { | |
33 | this.running = 0L; | |
34 | } | |
35 | ||
5d10d135 ASL |
36 | public LttngTrapState(Long running) { |
37 | this.running = running; | |
38 | } | |
39 | ||
cc6eec3e FC |
40 | @Override |
41 | public LttngTrapState clone() { | |
5d10d135 ASL |
42 | LttngTrapState newState = null; |
43 | ||
44 | try { | |
45 | newState = (LttngTrapState)super.clone(); | |
46 | ||
47 | // *** IMPORTANT *** | |
48 | // Basic type in java are immutable! | |
49 | // Thus, using assignation ("=") on basic type is CORRECT, | |
50 | // but we should ALWAYS use "new" or "clone()" on "non basic" type | |
51 | newState.running = this.running; | |
52 | } | |
53 | catch ( CloneNotSupportedException e ) { | |
54 | System.out.println("Cloning failed with : " + e.getMessage() ); | |
55 | } | |
56 | ||
57 | return newState; | |
58 | } | |
59 | ||
60 | // ======================================================================== | |
61 | // Methods | |
62 | // ======================================================================= | |
63 | public Long getRunning() { | |
64 | return running; | |
65 | } | |
66 | ||
67 | public void setRunning(Long running) { | |
68 | this.running = running; | |
69 | } | |
70 | ||
71 | public void incrementRunning() { | |
72 | running++; | |
73 | } | |
74 | ||
75 | public void decrementRunning() { | |
76 | if (running > 0) { | |
77 | running--; | |
78 | } | |
79 | } | |
e31e01e8 FC |
80 | |
81 | public String toString() { | |
82 | return "running : " + running; | |
83 | } | |
84 | ||
5d10d135 | 85 | } |