
org.jnosql.diana.mongodb.document.DocumentQueryConversor Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mongodb-driver Show documentation
Show all versions of mongodb-driver Show documentation
The Eclipse JNoSQL communication layer, Diana, implementation to MongoDB
The newest version!
/*
* Copyright (c) 2017 Otávio Santana and others
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Apache License v2.0 which accompanies this distribution.
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
* and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php.
*
* You may elect to redistribute this code under either of these licenses.
*
* Contributors:
*
* Otavio Santana
*/
package org.jnosql.diana.mongodb.document;
import com.mongodb.client.model.Filters;
import org.bson.conversions.Bson;
import org.jnosql.diana.api.TypeReference;
import org.jnosql.diana.api.document.Document;
import org.jnosql.diana.api.document.DocumentCondition;
import org.jnosql.diana.driver.ValueUtil;
import java.util.List;
import java.util.stream.Collectors;
final class DocumentQueryConversor {
private DocumentQueryConversor() {
}
public static Bson convert(DocumentCondition condition) {
Document document = condition.getDocument();
Object value = ValueUtil.convert(document.getValue());
switch (condition.getCondition()) {
case EQUALS:
return Filters.eq(document.getName(), value);
case GREATER_THAN:
return Filters.gt(document.getName(), value);
case GREATER_EQUALS_THAN:
return Filters.gte(document.getName(), value);
case LESSER_THAN:
return Filters.lt(document.getName(), value);
case LESSER_EQUALS_THAN:
return Filters.lte(document.getName(), value);
case IN:
List
© 2015 - 2025 Weber Informatics LLC | Privacy Policy