com.hazelcast.jet

## Class Util

- java.lang.Object
- - com.hazelcast.jet.Util

-     public final class Util
      extends Object

  Miscellaneous utility methods useful in DAG building logic.
  Since:
    3.0

- - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static <K,V> FunctionEx<EventJournalCacheEvent<K,V>,V>` | `cacheEventNewValue()` Returns a projection that extracts the new value from an `EventJournalCacheEvent`.
    `static <K,V> FunctionEx<EventJournalCacheEvent<K,V>,Map.Entry<K,V>>` | `cacheEventToEntry()` Returns a projection that converts the `EventJournalCacheEvent` to a `Map.Entry` using the event's new value as a value.
    `static <K,V> PredicateEx<EventJournalCacheEvent<K,V>>` | `cachePutEvents()` Returns a predicate for `Sources.cacheJournal(java.lang.String, com.hazelcast.jet.function.PredicateEx<? super com.hazelcast.cache.journal.EventJournalCacheEvent<K, V>>, com.hazelcast.jet.function.FunctionEx<? super com.hazelcast.cache.journal.EventJournalCacheEvent<K, V>, ? extends T>, com.hazelcast.jet.pipeline.JournalInitialPosition)` and `Sources.remoteCacheJournal(java.lang.String, com.hazelcast.client.config.ClientConfig, com.hazelcast.jet.function.PredicateEx<? super com.hazelcast.cache.journal.EventJournalCacheEvent<K, V>>, com.hazelcast.jet.function.FunctionEx<? super com.hazelcast.cache.journal.EventJournalCacheEvent<K, V>, ? extends T>, com.hazelcast.jet.pipeline.JournalInitialPosition)` that passes only `CREATED` and `UPDATED` events.
    `static <K,V> Map.Entry<K,V>` | `entry(K k, V v)` Returns a `Map.Entry` with the given key and value.
    `static long` | `idFromString(String str)` Parses the jobId formatted with `idToString(long)`.
    `static String` | `idToString(long id)` Converts a `long` job or execution ID to a string representation.
    `static <K,V> FunctionEx<EventJournalMapEvent<K,V>,V>` | `mapEventNewValue()` Returns a projection that extracts the new value from an `EventJournalMapEvent`.
    `static <K,V> FunctionEx<EventJournalMapEvent<K,V>,Map.Entry<K,V>>` | `mapEventToEntry()` Returns a projection that converts the `EventJournalMapEvent` to a `Map.Entry` using the event's new value as a value.
    `static <K,V> PredicateEx<EventJournalMapEvent<K,V>>` | `mapPutEvents()` Returns a predicate for `Sources.mapJournal(java.lang.String, com.hazelcast.jet.function.PredicateEx<? super com.hazelcast.map.journal.EventJournalMapEvent<K, V>>, com.hazelcast.jet.function.FunctionEx<? super com.hazelcast.map.journal.EventJournalMapEvent<K, V>, ? extends T>, com.hazelcast.jet.pipeline.JournalInitialPosition)` and `Sources.remoteMapJournal(java.lang.String, com.hazelcast.client.config.ClientConfig, com.hazelcast.jet.function.PredicateEx<? super com.hazelcast.map.journal.EventJournalMapEvent<K, V>>, com.hazelcast.jet.function.FunctionEx<? super com.hazelcast.map.journal.EventJournalMapEvent<K, V>, ? extends T>, com.hazelcast.jet.pipeline.JournalInitialPosition)` that passes only `ADDED` and `UPDATED` events.
    `static <T> CompletableFuture<T>` | `toCompletableFuture(ICompletableFuture<T> future)` Wraps Hazelcast IMDG's `ICompletableFuture` into Java's standard `CompletableFuture`.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Method Detail

    - #### entry

          public static <K,V> Map.Entry<K,V> entry(K k,
                                                   V v)

      Returns a `Map.Entry` with the given key and value.

    - #### mapPutEvents

          public static <K,V> PredicateEx<EventJournalMapEvent<K,V>> mapPutEvents()

      Returns a predicate for `Sources.mapJournal(java.lang.String, com.hazelcast.jet.function.PredicateEx<? super com.hazelcast.map.journal.EventJournalMapEvent<K, V>>, com.hazelcast.jet.function.FunctionEx<? super com.hazelcast.map.journal.EventJournalMapEvent<K, V>, ? extends T>, com.hazelcast.jet.pipeline.JournalInitialPosition)` and `Sources.remoteMapJournal(java.lang.String, com.hazelcast.client.config.ClientConfig, com.hazelcast.jet.function.PredicateEx<? super com.hazelcast.map.journal.EventJournalMapEvent<K, V>>, com.hazelcast.jet.function.FunctionEx<? super com.hazelcast.map.journal.EventJournalMapEvent<K, V>, ? extends T>, com.hazelcast.jet.pipeline.JournalInitialPosition)` that passes only `ADDED` and `UPDATED` events.

    - #### cachePutEvents

          public static <K,V> PredicateEx<EventJournalCacheEvent<K,V>> cachePutEvents()

      Returns a predicate for `Sources.cacheJournal(java.lang.String, com.hazelcast.jet.function.PredicateEx<? super com.hazelcast.cache.journal.EventJournalCacheEvent<K, V>>, com.hazelcast.jet.function.FunctionEx<? super com.hazelcast.cache.journal.EventJournalCacheEvent<K, V>, ? extends T>, com.hazelcast.jet.pipeline.JournalInitialPosition)` and `Sources.remoteCacheJournal(java.lang.String, com.hazelcast.client.config.ClientConfig, com.hazelcast.jet.function.PredicateEx<? super com.hazelcast.cache.journal.EventJournalCacheEvent<K, V>>, com.hazelcast.jet.function.FunctionEx<? super com.hazelcast.cache.journal.EventJournalCacheEvent<K, V>, ? extends T>, com.hazelcast.jet.pipeline.JournalInitialPosition)` that passes only `CREATED` and `UPDATED` events.

    - #### mapEventToEntry

          public static <K,V> FunctionEx<EventJournalMapEvent<K,V>,Map.Entry<K,V>> mapEventToEntry()

      Returns a projection that converts the `EventJournalMapEvent` to a `Map.Entry` using the event's new value as a value.
      See Also:
        `Sources.mapJournal(java.lang.String, com.hazelcast.jet.function.PredicateEx<? super com.hazelcast.map.journal.EventJournalMapEvent<K, V>>, com.hazelcast.jet.function.FunctionEx<? super com.hazelcast.map.journal.EventJournalMapEvent<K, V>, ? extends T>, com.hazelcast.jet.pipeline.JournalInitialPosition)`, `Sources.remoteMapJournal(java.lang.String, com.hazelcast.client.config.ClientConfig, com.hazelcast.jet.function.PredicateEx<? super com.hazelcast.map.journal.EventJournalMapEvent<K, V>>, com.hazelcast.jet.function.FunctionEx<? super com.hazelcast.map.journal.EventJournalMapEvent<K, V>, ? extends T>, com.hazelcast.jet.pipeline.JournalInitialPosition)`

    - #### mapEventNewValue

          public static <K,V> FunctionEx<EventJournalMapEvent<K,V>,V> mapEventNewValue()

      Returns a projection that extracts the new value from an `EventJournalMapEvent`.
      See Also:
        `Sources.mapJournal(java.lang.String, com.hazelcast.jet.function.PredicateEx<? super com.hazelcast.map.journal.EventJournalMapEvent<K, V>>, com.hazelcast.jet.function.FunctionEx<? super com.hazelcast.map.journal.EventJournalMapEvent<K, V>, ? extends T>, com.hazelcast.jet.pipeline.JournalInitialPosition)`, `Sources.remoteMapJournal(java.lang.String, com.hazelcast.client.config.ClientConfig, com.hazelcast.jet.function.PredicateEx<? super com.hazelcast.map.journal.EventJournalMapEvent<K, V>>, com.hazelcast.jet.function.FunctionEx<? super com.hazelcast.map.journal.EventJournalMapEvent<K, V>, ? extends T>, com.hazelcast.jet.pipeline.JournalInitialPosition)`

    - #### cacheEventToEntry

          public static <K,V> FunctionEx<EventJournalCacheEvent<K,V>,Map.Entry<K,V>> cacheEventToEntry()

      Returns a projection that converts the `EventJournalCacheEvent` to a `Map.Entry` using the event's new value as a value.
      See Also:
        `Sources.cacheJournal(java.lang.String, com.hazelcast.jet.function.PredicateEx<? super com.hazelcast.cache.journal.EventJournalCacheEvent<K, V>>, com.hazelcast.jet.function.FunctionEx<? super com.hazelcast.cache.journal.EventJournalCacheEvent<K, V>, ? extends T>, com.hazelcast.jet.pipeline.JournalInitialPosition)`, `Sources.remoteCacheJournal(java.lang.String, com.hazelcast.client.config.ClientConfig, com.hazelcast.jet.function.PredicateEx<? super com.hazelcast.cache.journal.EventJournalCacheEvent<K, V>>, com.hazelcast.jet.function.FunctionEx<? super com.hazelcast.cache.journal.EventJournalCacheEvent<K, V>, ? extends T>, com.hazelcast.jet.pipeline.JournalInitialPosition)`

    - #### cacheEventNewValue

          public static <K,V> FunctionEx<EventJournalCacheEvent<K,V>,V> cacheEventNewValue()

      Returns a projection that extracts the new value from an `EventJournalCacheEvent`.
      See Also:
        `Sources.mapJournal(java.lang.String, com.hazelcast.jet.function.PredicateEx<? super com.hazelcast.map.journal.EventJournalMapEvent<K, V>>, com.hazelcast.jet.function.FunctionEx<? super com.hazelcast.map.journal.EventJournalMapEvent<K, V>, ? extends T>, com.hazelcast.jet.pipeline.JournalInitialPosition)`, `Sources.remoteMapJournal(java.lang.String, com.hazelcast.client.config.ClientConfig, com.hazelcast.jet.function.PredicateEx<? super com.hazelcast.map.journal.EventJournalMapEvent<K, V>>, com.hazelcast.jet.function.FunctionEx<? super com.hazelcast.map.journal.EventJournalMapEvent<K, V>, ? extends T>, com.hazelcast.jet.pipeline.JournalInitialPosition)`

    - #### idToString

          public static String idToString(long id)

      Converts a `long` job or execution ID to a string representation. Currently it is an unsigned 16-digit hex number.

    - #### idFromString

          public static long idFromString(String str)

      Parses the jobId formatted with `idToString(long)`.

      The method is lenient: if the string doesn't match the structure output by `idToString` or if the string is null, it will return -1.

      Returns:
        the parsed ID or -1 if parsing failed.

    - #### toCompletableFuture

          public static <T> CompletableFuture<T> toCompletableFuture(ICompletableFuture<T> future)

      Wraps Hazelcast IMDG's `ICompletableFuture` into Java's standard `CompletableFuture`.
      Parameters:
        `future` - the future to wrap
      Returns:
        a new `CompletableFuture` wrapping the given one

Copyright © 2020. All rights reserved.