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

org.lumongo.client.result.BatchFetchResult Maven / Gradle / Ivy

There is a newer version: 0.52
Show newest version
package org.lumongo.client.result;

import org.lumongo.cluster.message.Lumongo.BatchFetchResponse;
import org.lumongo.cluster.message.Lumongo.FetchResponse;
import org.lumongo.fields.Mapper;

import java.util.ArrayList;
import java.util.List;

public class BatchFetchResult extends Result {
	
	@SuppressWarnings("unused")
	private BatchFetchResponse batchFetchResponse;
	
	private List fetchResults;
	
	public BatchFetchResult(List fetchResults) {
		this.fetchResults = fetchResults;
	}
	
	public BatchFetchResult(BatchFetchResponse batchFetchResponse) {
		this.batchFetchResponse = batchFetchResponse;
		
		this.fetchResults = new ArrayList();
		
		for (FetchResponse ft : batchFetchResponse.getFetchResponseList()) {
			fetchResults.add(new FetchResult(ft));
		}
	}
	
	public List getFetchResults() {
		return fetchResults;
	}
	
	public  List getDocuments(Mapper mapper) throws Exception {
		ArrayList list = new ArrayList();
		for (FetchResult fr : fetchResults) {
			if (fr.hasResultDocument()) {
				list.add(fr.getDocument(mapper));
			}
		}
		return list;
	}
	
	@Override
	public String toString() {
		return fetchResults.toString();
	}
	
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy