
org.jnosql.artemis.document.DocumentPage Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of artemis-document Show documentation
Show all versions of artemis-document Show documentation
Eclipse JNoSQL Mapping, Artemis API, to document NoSQL databases
The newest version!
/*
* 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.artemis.document;
import org.jnosql.artemis.Page;
import org.jnosql.artemis.Pagination;
import java.util.Collection;
import java.util.List;
import java.util.Objects;
import java.util.function.Supplier;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
* An implementation of {@link Page} to Column.
*
* @param the entity type
*/
final class DocumentPage implements Page {
private final DocumentTemplate template;
private final List entities;
private final DocumentQueryPagination query;
DocumentPage(DocumentTemplate template, List entities, DocumentQueryPagination query) {
this.template = template;
this.entities = entities;
this.query = query;
}
@Override
public Pagination getPagination() {
return query.getPagination();
}
@Override
public Page next() {
return template.select(query.next());
}
@Override
public List getContent() {
return entities;
}
@Override
public > C getContent(Supplier collectionFactory) {
Objects.requireNonNull(collectionFactory, "collectionFactory is required");
return get().collect(Collectors.toCollection(collectionFactory));
}
@Override
public Stream get() {
return entities.stream();
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
DocumentPage> that = (DocumentPage>) o;
return Objects.equals(entities, that.entities) &&
Objects.equals(query, that.query);
}
@Override
public int hashCode() {
return Objects.hash(entities, query);
}
@Override
public String toString() {
return "DocumentPage{" +
"entities=" + entities +
", query=" + query +
'}';
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy