public class ThermostatModel extends Object
Modifier and Type | Field and Description |
---|---|
static String |
CELCIUS
Celcius unit.
|
static String |
DEG
HTML representation of a degree.
|
static String |
FARENHEIGHT
Farenheight unit.
|
static String |
TARGET
The target tag.
|
static String |
TEMPERATURE
The temperature tag.
|
static String |
UNIT
The unit tag.
|
Constructor and Description |
---|
ThermostatModel()
Instantiates a
ThermostatModel . |
Modifier and Type | Method and Description |
---|---|
void |
addListener(ThermostatListener e)
Append a thermostat listener.
|
ThermostatListener[] |
getListeners()
Gets the listeners.
|
float |
getTargetTemperature()
Gets the target temperature.
|
float |
getTemperature()
Gets the temperature.
|
String |
getUnit()
Gets the unit.
|
void |
removeListener(ThermostatListener o)
Removes a ThermostatListener.
|
String |
serialize()
Gets a serialize version of the
ThermostatModel . |
void |
setTargetTemperature(float target)
Sets the target and notify the listeners.
|
void |
setTemperature(float temperature)
Sets the temperature and notify the listeners.
|
void |
setUnit(String unit)
Sets the unit.
|
String |
toString()
Returns a string representation of the object.
|
public static final String CELCIUS
public static final String DEG
public static final String FARENHEIGHT
public static final String TARGET
public static final String TEMPERATURE
public static final String UNIT
public ThermostatModel()
ThermostatModel
.public void addListener(ThermostatListener e)
e
- element to be appended to this listpublic ThermostatListener[] getListeners()
public float getTargetTemperature()
public float getTemperature()
public String getUnit()
public void removeListener(ThermostatListener o)
o
- collection containing elements to be removed from this listpublic String serialize()
ThermostatModel
.ThermostatModel
in JSON format.public void setTargetTemperature(float target)
target
- the target to set.public void setTemperature(float temperature)
temperature
- the temperature to set.public void setUnit(String unit)
unit
- the unit to set.public String toString()
Object
toString
method returns a
string that "textually represents" this object. The result should be a concise but informative
representation that is easy for a person to read. It is recommended that all subclasses override
this method.
The toString
method for class Object
returns a string consisting of the name of
the class of which the object is an instance, the at-sign character `@
', and the unsigned
hexadecimal representation of the hash code of the object. In other words, this method returns a
string equal to the value of:
getClass().getName() + '@' + Integer.toHexString(hashCode())