Skip to content

Commit

Permalink
creates provider
Browse files Browse the repository at this point in the history
  • Loading branch information
otaviojava committed Jun 12, 2019
1 parent 3120fb2 commit f948cde
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package org.jnosql.diana.document.query;

import jakarta.nosql.document.DocumentDeleteQuery.DocumentDelete;
import jakarta.nosql.document.DocumentDeleteQuery.DocumentDeleteProvider;

import java.util.Arrays;
import java.util.Collections;
import java.util.Objects;
import java.util.stream.Stream;

public final class DefaultDocumentDeleteProvider implements DocumentDeleteProvider {

@Override
public DocumentDelete apply(String[] documents) {
if(Stream.of(documents).anyMatch(Objects::isNull)) {
throw new NullPointerException("there is null document in the query");
}
return new DefaultDeleteQueryBuilder(Arrays.asList(documents));
}

@Override
public DocumentDelete get() {
return new DefaultDeleteQueryBuilder(Collections.emptyList());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
*
* Copyright (c) 2019 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.document.query;

import jakarta.nosql.document.DocumentQuery.DocumentSelect;
import jakarta.nosql.document.DocumentQuery.DocumentSelectProvider;

import java.util.Arrays;
import java.util.Collections;
import java.util.Objects;
import java.util.stream.Stream;

/**
* The default implementation of {@link DocumentSelectProvider}
*/
public final class DefaultDocumentSelectProvider implements DocumentSelectProvider {

@Override
public DocumentSelect apply(String[] documents) {
if(Stream.of(documents).anyMatch(Objects::isNull)) {
throw new NullPointerException("there is null document in the query");
}
return new DefaultSelectQueryBuilder(Arrays.asList(documents));
}

@Override
public DocumentSelect get() {
return new DefaultSelectQueryBuilder(Collections.emptyList());
}
}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
org.jnosql.diana.document.query.DefaultDocumentDeleteSupplier
org.jnosql.diana.document.query.DefaultDocumentDeleteProvider

0 comments on commit f948cde

Please sign in to comment.