Class Event<T>

  • Type Parameters:
    T - The type of the event data.
    Direct Known Subclasses:
    ComplianceEvent

    public class Event<T>
    extends java.lang.Object
     An Event is the kind of event that can be emitted by a device. Event includes:
     1. A primitive type (Type of the event data)
     2. A semantic @type (a string identifying a type from the linked context)
     3. A unit (SI unit of the event data)
     4. A title (A name for the event)
     5. A description (A short description on the event)
     6. A minimum and maximum (Range of the event data)
     7. multipleOf (If input data is of numeric type it should be the multiple of this)
     8. A links array (An array of links linking to one or more representations of an Event resource, each with an implied default rel=event)
     
     Example code snippet to create and add an event to a thing:
     
     Consider a light bulb which can emit an event of overheating
     
    	Map<String, Object> overheatedMetadata = new HashMap<String, Object>();
    	overheatedMetadata.put("description","The bulb has exceeded its safe operating temperature");
    	overheatedMetadata.put("type", "number");
    	overheatedMetadata.put("unit", "degree celsius");
    	thing.addAvailableEvent("overheated", overheatedMetadata);
      
    
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  Event.eventType
      Type of event.
    • Constructor Summary

      Constructors 
      Constructor Description
      Event​(Thing thing, java.lang.String name)
      Initialize the object.
      Event​(Thing thing, java.lang.String name, T data)
      Initialize the object.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      com.google.gson.JsonObject asEventDescription()
      Get the event description.
      T getData()
      Get the event's data.
      java.lang.String getName()
      Get the event's name.
      Thing getThing()
      Get the thing associated with this event.
      java.lang.String getTime()
      Get the event's timestamp.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Event

        public Event​(Thing thing,
                     java.lang.String name)
        Initialize the object.
        Parameters:
        thing - Thing this event belongs to
        name - Name of the event
      • Event

        public Event​(Thing thing,
                     java.lang.String name,
                     T data)
        Initialize the object.
        Parameters:
        thing - Thing this event belongs to
        name - Name of the event
        data - Data associated with the event
    • Method Detail

      • asEventDescription

        public com.google.gson.JsonObject asEventDescription()
        Get the event description.
        Returns:
        Description of the event as a JSONObject.
      • getThing

        public Thing getThing()
        Get the thing associated with this event.
        Returns:
        The thing.
      • getName

        public java.lang.String getName()
        Get the event's name.
        Returns:
        The name.
      • getData

        public T getData()
        Get the event's data.
        Returns:
        The data.
      • getTime

        public java.lang.String getTime()
        Get the event's timestamp.
        Returns:
        The time.