All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.pincette.mongo.streams.ReplaceRoot Maven / Gradle / Ivy

The newest version!
package net.pincette.mongo.streams;

import static net.pincette.json.JsonUtil.isObject;
import static net.pincette.util.Util.must;

import java.util.concurrent.Flow.Processor;
import javax.json.JsonObject;
import javax.json.JsonValue;
import net.pincette.rs.streams.Message;

/**
 * The $replaceRoot operator.
 *
 * @author Werner Donné
 */
class ReplaceRoot {
  private static final String NEW_ROOT = "newRoot";

  private ReplaceRoot() {}

  static Processor, Message> stage(
      final JsonValue expression, final Context context) {
    must(isObject(expression) && expression.asJsonObject().containsKey(NEW_ROOT));

    return ReplaceWith.stage(expression.asJsonObject().getValue("/" + NEW_ROOT), context);
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy