Class ThingEventToThingConverter


  • public final class ThingEventToThingConverter
    extends java.lang.Object
    Helpers and utils for converting ThingEvents to Things.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.util.Optional<Thing> mergeThingWithExtraFields​(org.eclipse.ditto.base.model.signals.Signal<?> signal, org.eclipse.ditto.json.JsonFieldSelector extraFields, org.eclipse.ditto.json.JsonObject extra)
      Merge any thing information in a signal event together with extra fields from signal enrichment.
      static java.util.Optional<Thing> thingEventToThing​(ThingEvent<?> thingEvent)
      Creates a Thing from the passed ThingEvent.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • thingEventToThing

        public static java.util.Optional<Thing> thingEventToThing​(ThingEvent<?> thingEvent)
        Creates a Thing from the passed ThingEvent.
        Parameters:
        thingEvent - the ThingEvent to extract the correlating Thing from
        Returns:
        the Thing represented by the passed in ThingEvent
      • mergeThingWithExtraFields

        public static java.util.Optional<Thing> mergeThingWithExtraFields​(org.eclipse.ditto.base.model.signals.Signal<?> signal,
                                                                          @Nullable
                                                                          org.eclipse.ditto.json.JsonFieldSelector extraFields,
                                                                          org.eclipse.ditto.json.JsonObject extra)
        Merge any thing information in a signal event together with extra fields from signal enrichment. Thing events contain thing information. All other signals do not contain thing information. Extra fields contain thing information if it is not empty. If thing information exists in any of the 2 sources, then merge the information from both sources to create a thing, with priority given to the thing information extracted by the signal.
        Parameters:
        signal - the signal.
        extraFields - selected extra fields to enrich the signal with.
        extra - value of the extra fields.
        Returns:
        the merged thing if thing information exists in any of the 2 sources, or an empty optional otherwise.