Class Util

java.lang.Object
net.pincette.jes.Util

public class Util extends Object
Some general utilities.
Since:
3.0
Author:
Werner Donné
  • Method Details

    • compose

      public static Reducer compose(Reducer validator, Reducer reducer)
      Returns a reducer that first calls validator and if the result doesn't contain any errors it calls reducer.
      Parameters:
      validator - the given validator.
      reducer - the given reducer.
      Returns:
      The composed function.
      Since:
      1.0
    • getUsername

      public static Optional<String> getUsername(JsonObject json)
      Returns the username from "/_jwt/sub".
      Parameters:
      json - the given object.
      Returns:
      The username.
      Since:
      1.0
    • isJesObject

      public static boolean isJesObject(JsonObject json)
      Checks if json is a JSON Event Sourcing object. This means it has the fields _id and _type.
      Parameters:
      json - the given object.
      Returns:
      The check report.
      Since:
      1.1.2
      See Also:
    • isManagedObject

      public static boolean isManagedObject(JsonObject json)
      Checks if json is a managed object. This means it has the fields _id, _type and _seq.
      Parameters:
      json - the given object.
      Returns:
      The check report.
      Since:
      1.0
      See Also:
    • isManagedObject

      public static boolean isManagedObject(JsonObject json, String type, String id)
      Checks if json is a managed object with the fields _id and _type set to id and type respectively.
      Parameters:
      json - the given object.
      type - the aggregate type.
      id - the ID of the instance.
      Returns:
      The check report.
      Since:
      1.0
    • reconstruct

      public static Stream<JsonObject> reconstruct(JsonArray events)
      Reconstructs aggregate instances using a sequence of events.
      Parameters:
      events - the array of events, which should start at _seq equal to 0 and which should no holes in the numbering.
      Returns:
      The reconstructed aggregate instance stream. The events are applied one after the other and each intermediate aggregate instance is emitted in the stream.
      Since:
      1.2
    • reconstruct

      public static Stream<JsonObject> reconstruct(JsonParser events)
      Reconstructs aggregate instances using a sequence of events.
      Parameters:
      events - the event parser, which should start returning objects at _seq equal to 0 and which should no holes in the numbering.
      Returns:
      The reconstructed aggregate instance stream. The events are applied one after the other and each intermediate aggregate instance is emitted in the stream.
      Since:
      1.2
    • reconstruct

      public static Stream<JsonObject> reconstruct(Stream<? extends JsonValue> events)
      Reconstructs aggregate instances using a sequence of events.
      Parameters:
      events - the stream of events, which should start at _seq equal to 0 and which should no holes in the numbering.
      Returns:
      The reconstructed aggregate instance stream. The events are applied one after the other and each intermediate aggregate instance is emitted in the stream.
      Since:
      1.2
    • removeTechnical

      public static JsonObjectBuilder removeTechnical(JsonObject json)
      Removes all the technical fields JES uses.
      Parameters:
      json - the given JSON object.
      Returns:
      The new JSON object.
      Since:
      1.4.2
      See Also: