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

com.noenv.wiremongo.mapping.find.FindBase Maven / Gradle / Ivy

There is a newer version: 4.5.10
Show newest version
package com.noenv.wiremongo.mapping.find;

import com.noenv.wiremongo.command.find.FindBaseCommand;
import com.noenv.wiremongo.mapping.WithQuery;
import io.vertx.core.json.JsonArray;
import io.vertx.core.json.JsonObject;

import java.util.List;
import java.util.stream.Collectors;

public abstract class FindBase> extends WithQuery, U, C> {

  protected FindBase() {
    this("find");
  }

  protected FindBase(String method) {
    super(method);
  }

  protected FindBase(JsonObject json) {
    super(json);
  }

  @Override
  public C returns(final List response) {
    return super.stub(c -> null == response ? null : response.stream().map(JsonObject::copy).collect(java.util.stream.Collectors.toList()));
  }

  @Override
  protected List parseResponse(Object jsonValue) {
    return ((JsonArray) jsonValue).stream()
      .map(JsonObject.class::cast)
      .collect(Collectors.toList());
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy