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

com.lordofthejars.nosqlunit.marklogic.content.DataSetReader Maven / Gradle / Ivy

The newest version!
package com.lordofthejars.nosqlunit.marklogic.content;

import com.marklogic.client.document.DocumentManager;
import com.marklogic.client.io.marker.ContentHandle;
import com.marklogic.client.io.marker.ContentHandleFactory;

import java.util.Map;
import java.util.Set;

import static java.util.stream.Collectors.toMap;

public class DataSetReader {

    private DocumentManager documentManager;

    private ContentHandleFactory contentHandleFactory;

    public DataSetReader(DocumentManager documentManager, ContentHandleFactory contentHandleFactory) {
        this.documentManager = documentManager;
        this.contentHandleFactory = contentHandleFactory;
    }

    public  Map> read(Set contents, Class type) {
        return contents.stream().collect(toMap(Content::getUri, c ->
                        (ContentHandle) documentManager.read(c.getUri(), contentHandleFactory.newHandle(type))
                )
        );
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy