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

com.eightkdata.mongowp.messages.utils.IterableDocumentProvider Maven / Gradle / Ivy

There is a newer version: 0.50.0
Show newest version

package com.eightkdata.mongowp.messages.utils;

import com.eightkdata.mongowp.annotations.Ethereal;
import com.eightkdata.mongowp.annotations.Material;
import com.eightkdata.mongowp.bson.BsonDocument;
import com.eightkdata.mongowp.bson.utils.BsonDocumentReader;
import com.eightkdata.mongowp.bson.utils.BsonDocumentReader.AllocationType;
import com.google.common.collect.FluentIterable;
import java.util.Collections;

/**
 * This class is a factory that creates stream like iterables of type BsonDocument.
 *
 * The generated iterables can be configured to use different {@linkplain AllocationType heap allocations}.
 *
 * @param 
 */
public abstract class IterableDocumentProvider {
    private static final IterableDocumentProvider EMPTY
            = new SimpleIterableDocumentProvider<>(Collections.emptyList());

    @Ethereal("my-own-context")
    public abstract FluentIterable getIterable(BsonDocumentReader.AllocationType algorithm);

    @Material
    @SuppressWarnings("unchecked")
    public static  IterableDocumentProvider of() {
        return (IterableDocumentProvider) EMPTY;
    }

    @Ethereal("argument-context")
    public static  IterableDocumentProvider of(@Ethereal("whatever") E1 element) {
        return new SimpleIterableDocumentProvider<>(Collections.singleton(element));
    }

    @Ethereal("argument-context")
    public static  IterableDocumentProvider of(@Ethereal("whatever") Iterable elements) {
        return new SimpleIterableDocumentProvider<>(elements);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy