Class AlarmData
- java.lang.Object
-
- org.osgi.service.dal.FunctionData
-
- org.osgi.service.dal.functions.data.AlarmData
-
- All Implemented Interfaces:
java.lang.Comparable<java.lang.Object>
public class AlarmData extends FunctionData
Function alarm data. It cares about the alarm type, severity, timestamp and additional metadata. It doesn't support unit. The alarm type is mapped toFunctionDatavalue.- See Also:
Alarm,FunctionData
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringFIELD_SEVERITYRepresents the severity field name.static java.lang.StringFIELD_TYPERepresents the type field name.static intSEVERITY_CRITICALThe severity rating indicates that there a critical alarm.static intSEVERITY_MAJORThe severity rating indicates that there is a major alarm.static intSEVERITY_MINORThe severity rating indicates that there is a minor alarm.static intSEVERITY_UNDEFINEDThe severity constant indicates that there is no severity rating for this alarm.static intTYPE_ACCESS_CONTROLThe alarm type indicates that there is access control issue.static intTYPE_BURGLARThe alarm type indicates that there is a burglar notification.static intTYPE_COLDThe alarm type indicates that temperature is too low.static intTYPE_GAS_COThe alarm type indicates that carbon monoxide (CO) is detected.static intTYPE_GAS_CO2The alarm type indicates that carbon dioxide (CO2) is detected.static intTYPE_HARDWARE_FAILThe alarm type indicates that there is hardware failure.static intTYPE_HEATThe alarm type indicates that temperature is too high.static intTYPE_POWER_FAILThe alarm type indicates a power cut.static intTYPE_SMOKEThe alarm type indicates that smoke is detected.static intTYPE_SOFTWARE_FAILThe alarm type indicates that there is software failure.static intTYPE_TAMPERThe alarm type for a tamper indication.static intTYPE_UNDEFINEDThe alarm type indicates that the type is not specified.static intTYPE_WATERThe alarm type indicates that a water leak is detected.-
Fields inherited from class org.osgi.service.dal.FunctionData
DESCRIPTION, FIELD_METADATA, FIELD_TIMESTAMP
-
-
Constructor Summary
Constructors Constructor Description AlarmData(long timestamp, java.util.Map<java.lang.String,?> metadata, int severity, int type)Constructs newAlarmDatainstance with the specified arguments.AlarmData(java.util.Map<java.lang.String,?> fields)Constructs newAlarmDatainstance with the specified field values.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intcompareTo(java.lang.Object o)Compares thisAlarmDatainstance with the given argument.booleanequals(java.lang.Object o)TwoAlarmDatainstances are equal if they contain equal metadata, timestamp, type and severity.intgetSeverity()Returns the alarm severity.intgetType()Returns the alarm type.inthashCode()Returns the hash code for thisAlarmDataobject.java.lang.StringtoString()Returns the string representation of this alarm data.-
Methods inherited from class org.osgi.service.dal.FunctionData
getMetadata, getTimestamp
-
-
-
-
Field Detail
-
FIELD_SEVERITY
public static final java.lang.String FIELD_SEVERITY
Represents the severity field name. The field value is available withgetSeverity(). The field type isint. The constant can be used as a key toAlarmData(Map).- See Also:
- Constant Field Values
-
FIELD_TYPE
public static final java.lang.String FIELD_TYPE
Represents the type field name. The field value is available withgetType(). The field type isint. The constant can be used as a key toAlarmData(Map).- See Also:
- Constant Field Values
-
TYPE_UNDEFINED
public static final int TYPE_UNDEFINED
The alarm type indicates that the type is not specified.- See Also:
- Constant Field Values
-
TYPE_ACCESS_CONTROL
public static final int TYPE_ACCESS_CONTROL
The alarm type indicates that there is access control issue. For example, the alarm can indicate that the door is unlocked.- See Also:
- Constant Field Values
-
TYPE_BURGLAR
public static final int TYPE_BURGLAR
The alarm type indicates that there is a burglar notification. For example, the alarm can indicate that the glass is broken.- See Also:
- Constant Field Values
-
TYPE_COLD
public static final int TYPE_COLD
The alarm type indicates that temperature is too low.- See Also:
- Constant Field Values
-
TYPE_GAS_CO
public static final int TYPE_GAS_CO
The alarm type indicates that carbon monoxide (CO) is detected.- See Also:
- Constant Field Values
-
TYPE_GAS_CO2
public static final int TYPE_GAS_CO2
The alarm type indicates that carbon dioxide (CO2) is detected.- See Also:
- Constant Field Values
-
TYPE_HEAT
public static final int TYPE_HEAT
The alarm type indicates that temperature is too high.- See Also:
- Constant Field Values
-
TYPE_HARDWARE_FAIL
public static final int TYPE_HARDWARE_FAIL
The alarm type indicates that there is hardware failure.- See Also:
- Constant Field Values
-
TYPE_POWER_FAIL
public static final int TYPE_POWER_FAIL
The alarm type indicates a power cut.- See Also:
- Constant Field Values
-
TYPE_SMOKE
public static final int TYPE_SMOKE
The alarm type indicates that smoke is detected.- See Also:
- Constant Field Values
-
TYPE_SOFTWARE_FAIL
public static final int TYPE_SOFTWARE_FAIL
The alarm type indicates that there is software failure.- See Also:
- Constant Field Values
-
TYPE_TAMPER
public static final int TYPE_TAMPER
The alarm type for a tamper indication.- See Also:
- Constant Field Values
-
TYPE_WATER
public static final int TYPE_WATER
The alarm type indicates that a water leak is detected.- See Also:
- Constant Field Values
-
SEVERITY_UNDEFINED
public static final int SEVERITY_UNDEFINED
The severity constant indicates that there is no severity rating for this alarm.- See Also:
- Constant Field Values
-
SEVERITY_MINOR
public static final int SEVERITY_MINOR
The severity rating indicates that there is a minor alarm. The severity priority is lower thanSEVERITY_MAJORandSEVERITY_CRITICAL.- See Also:
- Constant Field Values
-
SEVERITY_MAJOR
public static final int SEVERITY_MAJOR
The severity rating indicates that there is a major alarm. The severity priority is higher thanSEVERITY_MINORand lower thanSEVERITY_CRITICAL.- See Also:
- Constant Field Values
-
SEVERITY_CRITICAL
public static final int SEVERITY_CRITICAL
The severity rating indicates that there a critical alarm. The severity priority is higher thanSEVERITY_MINORandSEVERITY_MAJOR.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
AlarmData
public AlarmData(java.util.Map<java.lang.String,?> fields)
Constructs newAlarmDatainstance with the specified field values. The map keys must match to the field names. The map values will be assigned to the appropriate class fields. For example, the maps can be: {"severity"=Integer(1)...}. That map will initialize theFIELD_SEVERITYfield with 1. If severity is missing,SEVERITY_UNDEFINEDis used.FIELD_SEVERITY- optional field. The value type must beInteger.FIELD_TYPE- optional field. The value type must beInteger.
- Parameters:
fields- Contains the newAlarmDatainstance field values.- Throws:
java.lang.ClassCastException- If the field value types are not expected.java.lang.IllegalArgumentException- If the alarm severity is invalid.java.lang.NullPointerException- If the fields map isnull.
-
AlarmData
public AlarmData(long timestamp, java.util.Map<java.lang.String,?> metadata, int severity, int type)Constructs newAlarmDatainstance with the specified arguments.- Parameters:
timestamp- The alarm data timestamp optional field.metadata- The alarm data metadata optional field.severity- The alarm data severity optional field.type- The alarm data type optional field.- Throws:
java.lang.IllegalArgumentException- If the alarm severity is invalid.
-
-
Method Detail
-
getType
public int getType()
Returns the alarm type. The type can be one of the predefined: Zero and positive values are reserved for this definition and further extensions of the alarm types. Custom types can be used only as negative values to prevent potential collisions.- Returns:
- The alarm type.
-
getSeverity
public int getSeverity()
Returns the alarm severity. The severity can be one of:- Returns:
- The alarm severity.
-
equals
public boolean equals(java.lang.Object o)
TwoAlarmDatainstances are equal if they contain equal metadata, timestamp, type and severity.- Overrides:
equalsin classFunctionData- Parameters:
o- The object to compare this data.- Returns:
trueif this object is equivalent to the specified one.- See Also:
FunctionData.equals(java.lang.Object)
-
hashCode
public int hashCode()
Returns the hash code for thisAlarmDataobject. The hash code is a sum ofFunctionData.hashCode(), the alarm severity and the alarm type.- Overrides:
hashCodein classFunctionData- Returns:
- The hash code of this
AlarmDataobject. - See Also:
FunctionData.hashCode()
-
compareTo
public int compareTo(java.lang.Object o)
Compares thisAlarmDatainstance with the given argument. If the argument is notAlarmData, it throwsClassCastException. Otherwise, this method returns:-1if this instance field is less than a field of the specified argument.0if all fields are equivalent.1if this instance field is greater than a field of the specified argument.
- Specified by:
compareToin interfacejava.lang.Comparable<java.lang.Object>- Overrides:
compareToin classFunctionData- Parameters:
o-AlarmDatato be compared.- Returns:
-1,0or1depending on the comparison rules.- Throws:
java.lang.ClassCastException- If the method argument is not of typeAlarmData.- See Also:
Comparable.compareTo(java.lang.Object)
-
toString
public java.lang.String toString()
Returns the string representation of this alarm data.- Overrides:
toStringin classjava.lang.Object- Returns:
- The string representation of this alarm data.
-
-