public class BasicSensor<T> extends java.lang.Object implements Sensor<T>
Sensor
s.Constructor and Description |
---|
BasicSensor() |
BasicSensor(java.lang.Class<T> type,
java.lang.String name)
name is typically a dot-separated identifier; description is optional
|
BasicSensor(java.lang.Class<T> type,
java.lang.String name,
java.lang.String description) |
BasicSensor(com.google.common.reflect.TypeToken<T> typeToken,
java.lang.String name,
java.lang.String description) |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(java.lang.Object other) |
java.lang.String |
getDescription()
Returns the description of the sensor, for display.
|
java.lang.String |
getName()
Returns the name of the sensor, in a dot-separated namespace.
|
java.util.List<java.lang.String> |
getNameParts()
Returns the constituent parts of the sensor name as a
List . |
java.lang.Class<? super T> |
getType()
Returns the Java
Class for the sensor data. |
java.lang.String |
getTypeName()
Returns the type of the sensor data, as a
String representation of the class name. |
com.google.common.reflect.TypeToken<T> |
getTypeToken()
Returns the Guava TypeToken (including generics info)
|
int |
hashCode() |
SensorEvent<T> |
newEvent(Entity producer,
T value)
Create a new
SensorEvent object for a specific Entity and data point. |
java.lang.String |
toString() |
public BasicSensor()
public BasicSensor(java.lang.Class<T> type, java.lang.String name)
public BasicSensor(java.lang.Class<T> type, java.lang.String name, java.lang.String description)
public BasicSensor(com.google.common.reflect.TypeToken<T> typeToken, java.lang.String name, java.lang.String description)
public com.google.common.reflect.TypeToken<T> getTypeToken()
Sensor
getTypeToken
in interface Sensor<T>
Sensor.getTypeToken()
public java.lang.Class<? super T> getType()
Sensor
Class
for the sensor data.
This returns a "super" of T only in the case where T is generified,
and in such cases it returns the Class instance for the unadorned T ---
i.e. for List<String> this returns Class ---
this is of course because there is no actual Class<List<String>> instance.
getType
in interface Sensor<T>
Sensor.getType()
public java.lang.String getTypeName()
Sensor
String
representation of the class name.
(Useful for contexts where Type is not accessible.)getTypeName
in interface Sensor<T>
Sensor.getTypeName()
public java.lang.String getName()
Sensor
getName
in interface Sensor<T>
Sensor.getName()
public java.util.List<java.lang.String> getNameParts()
Sensor
List
.getNameParts
in interface Sensor<T>
Sensor.getNameParts()
public java.lang.String getDescription()
Sensor
getDescription
in interface Sensor<T>
Sensor.getDescription()
public SensorEvent<T> newEvent(Entity producer, T value)
Sensor
SensorEvent
object for a specific Entity
and data point.newEvent
in interface Sensor<T>
Sensor.newEvent(Entity, Object)
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object other)
equals
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object