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

net.ravendb.client.documents.session.operations.lazy.LazyRevisionOperations Maven / Gradle / Ivy

There is a newer version: 6.0.1
Show newest version
package net.ravendb.client.documents.session.operations.lazy;

import net.ravendb.client.documents.Lazy;
import net.ravendb.client.documents.session.DocumentSession;
import net.ravendb.client.documents.session.ILazyRevisionsOperations;
import net.ravendb.client.documents.session.operations.GetRevisionOperation;
import net.ravendb.client.json.MetadataAsDictionary;

import java.util.Date;
import java.util.List;
import java.util.Map;

public class LazyRevisionOperations implements ILazyRevisionsOperations {

    protected final DocumentSession delegate;

    public LazyRevisionOperations(DocumentSession delegate) {
        this.delegate = delegate;
    }

    @Override
    public  Lazy get(Class clazz, String changeVector) {
        GetRevisionOperation operation = new GetRevisionOperation(delegate, changeVector);
        LazyRevisionOperation lazyRevisionOperation = new LazyRevisionOperation<>(clazz, operation, LazyRevisionOperation.Mode.SINGLE);
        return delegate.addLazyOperation(clazz, lazyRevisionOperation, null);
    }

    @Override
    public Lazy> getMetadataFor(String id) {
        return getMetadataFor(id, 0, 25);
    }

    @Override
    public Lazy> getMetadataFor(String id, int start) {
        return getMetadataFor(id, start, 25);
    }

    @SuppressWarnings("unchecked")
    @Override
    public Lazy> getMetadataFor(String id, int start, int pageSize) {
        GetRevisionOperation operation = new GetRevisionOperation(delegate, id, start, pageSize);
        LazyRevisionOperation lazyRevisionOperation = new LazyRevisionOperation<>(MetadataAsDictionary.class, operation, LazyRevisionOperation.Mode.LIST_OF_METADATA);
        return delegate.addLazyOperation((Class>)(Class)List.class, lazyRevisionOperation, null);
    }

    @SuppressWarnings("unchecked")
    @Override
    public  Lazy> get(Class clazz, String[] changeVectors) {
        GetRevisionOperation operation = new GetRevisionOperation(delegate, changeVectors);
        LazyRevisionOperation lazyRevisionOperation = new LazyRevisionOperation<>(clazz, operation, LazyRevisionOperation.Mode.MAP);
        return delegate.addLazyOperation((Class>)(Class)Map.class, lazyRevisionOperation, null);
    }

    @Override
    public  Lazy get(Class clazz, String id, Date date) {
        GetRevisionOperation operation = new GetRevisionOperation(delegate, id, date);
        LazyRevisionOperation lazyRevisionOperation = new LazyRevisionOperation<>(clazz, operation, LazyRevisionOperation.Mode.SINGLE);
        return delegate.addLazyOperation(clazz, lazyRevisionOperation, null);
    }

    @Override
    public  Lazy> getFor(Class clazz, String id) {
        return getFor(clazz, id, 0, 25);
    }

    @Override
    public  Lazy> getFor(Class clazz, String id, int start) {
        return getFor(clazz, id, start, 25);
    }

    @SuppressWarnings("unchecked")
    @Override
    public  Lazy> getFor(Class clazz, String id, int start, int pageSize) {
        GetRevisionOperation operation = new GetRevisionOperation(delegate, id, start, pageSize);
        LazyRevisionOperation lazyRevisionOperation = new LazyRevisionOperation<>(clazz, operation, LazyRevisionOperation.Mode.MULTI);
        return delegate.addLazyOperation((Class>)(Class)List.class, lazyRevisionOperation, null);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy