View Javadoc

1   /*
2    * @(#)DeviceState.java Feb 17, 2004
3    * 
4    * Copyright (c) 2003-2005 Delft University of Technology, Jaffalaan 5, 2628 BX
5    * Delft, the Netherlands. All rights reserved.
6    * 
7    * See for project information <a href="http://www.simulation.tudelft.nl/">
8    * www.simulation.tudelft.nl </a>.
9    * 
10   * The source code and binary code of this software is proprietary information
11   * of Delft University of Technology.
12   */
13  
14  package nl.tudelft.simulation.messaging.devices.components;
15  
16  import java.io.Serializable;
17  
18  /***
19   * The state of the device as a resource, indicating whether it is working or
20   * not. <br>
21   * <br>
22   * Copyright (c) 2003-2005 Delft University of Technology, Jaffalaan 5, 2628 BX
23   * Delft, the Netherlands. All rights reserved.
24   * 
25   * See for project information <a href="http://www.simulation.tudelft.nl/">
26   * www.simulation.tudelft.nl </a>.
27   * 
28   * The source code and binary code of this software is proprietary information
29   * of Delft University of Technology.
30   * 
31   * @author <a href="http://www.tbm.tudelft.nl/webstaf/peterja/index.htm">Peter
32   *         Jacobs </a>, <a
33   *         href="mailto:s.p.a.vanhouten@tbm.tudelft.nl">Stijn-Pieter van Houten
34   *         </a>, <a
35   *         href="http://www.tbm.tudelft.nl/webstaf/alexandv/index.htm">Alexander
36   *         Verbraeck </a>
37   * @version $$Revision: 1.3 $$ $$Date: 2005/04/08 11:29:12 $$
38   */
39  public class DeviceState implements Serializable
40  {
41  	/*** the serial version uid */
42  	private static final long serialVersionUID = 12L;
43  
44  	/*** static state to indicate idle device, in other words ready to use */
45  	public static final DeviceState IDLE = new DeviceState("IDLE", true);
46  
47  	/*** static state to indicate busy device, operation has to wait */
48  	public static final DeviceState BUSY = new DeviceState("BUSY", false);
49  
50  	/*** internal state */
51  	private String description = null;
52  
53  	/*** working or not */
54  	private boolean working = true;
55  
56  	/***
57  	 * creates a state
58  	 * 
59  	 * @param description the description of this device
60  	 * @param working indicates whether this state is a working state
61  	 */
62  	public DeviceState(final String description, final boolean working)
63  	{
64  		super();
65  		this.description = description;
66  		this.working = working;
67  	}
68  
69  	/***
70  	 * @return Returns the state description.
71  	 */
72  	public String getDescription()
73  	{
74  		return this.description;
75  	}
76  
77  	/***
78  	 * @return Returns whether the device is working.
79  	 */
80  	public boolean isWorking()
81  	{
82  		return this.working;
83  	}
84  
85  	/***
86  	 * @see java.lang.Object#equals(java.lang.Object)
87  	 */
88  	public boolean equals(final Object arg0)
89  	{
90  		if (!(arg0 instanceof DeviceState))
91  		{
92  			return false;
93  		}
94  		return this.description == ((DeviceState) arg0).description;
95  	}
96  
97  	/***
98  	 * @see java.lang.Object#hashCode()
99  	 */
100 	public int hashCode()
101 	{
102 		return this.description.hashCode();
103 	}
104 
105 	/***
106 	 * @see java.lang.Object#toString()
107 	 */
108 	public String toString()
109 	{
110 		return this.description;
111 	}
112 }