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

ftl.data.mongo.method.$$MongoRepositoryFindMethodBodyTemplateftl Maven / Gradle / Ivy

There is a newer version: 0.11
Show newest version
<#include "../mongo-lib.javaftl">
<#-- -------------------------------------------------------------------------------------------------------- -->
<#if QUERY??>
${createBsonVar('query', QUERY)}

<#if PROJECTION??>
${createBsonVar('projection', PROJECTION)}

<#if HINT??>
${createBsonVar('hint', HINT)}

<#if SORT??>
${createBsonVar('sort', SORT)}

<#-- -------------------------------------------------------------------------------------------------------- -->
<#if QUERY??>
final FindPublisher result = collection
        .find(query)
<#else>
final FindPublisher result = collection
        .find()

<#-- -------------------------------------------------------------------------------------------------------- -->
<#if PROJECTION??>
        .projection(projection)

<#if HINT??>
        .hint(hint)

<#if SORT??>
        .sort(sort)

<#if LIMIT??>
        .limit(${LIMIT})

<#if SKIP??>
        .skip(${SKIP})

        .returnKey(false);
<#-- -------------------------------------------------------------------------------------------------------- -->
<#-- -------------------------------------------------------------------------------------------------------- -->
<#-- -------------------------------------------------------------------------------------------------------- -->
<#if RETURN.oneItem>
<#if RETURN.mono>
return Mono.from(result)
        .map(${ENTITY_CONVERTER}::fromDB);
<#-- -------------------------------------------------------------------------------------------------------- -->
<#elseif RETURN.future && !RETURN.optional>
return new PublisherToRequiredMonoFutureAdapter<>(
        result,
        useOptionalExceptionSupplier(${RETURN.simpleReactiveType}.class, ${RETURN.simpleResultType}.class)
).thenApply(${ENTITY_CONVERTER}::fromDB);
<#-- -------------------------------------------------------------------------------------------------------- -->
<#elseif RETURN.future && RETURN.optional>
return new PublisherToOptionalMonoFutureAdapter<>(result)
        .thenApply(o -> o.map(${ENTITY_CONVERTER}::fromDB));
<#-- -------------------------------------------------------------------------------------------------------- -->
<#elseif RETURN.single>
return Single.fromPublisher(result)
        .map(${ENTITY_CONVERTER}::fromDB);
<#-- -------------------------------------------------------------------------------------------------------- -->
<#elseif RETURN.maybe>
return Flowable.fromPublisher(result)
        .firstElement()
        .map(${ENTITY_CONVERTER}::fromDB);
<#-- -------------------------------------------------------------------------------------------------------- -->
<#else>
//"The RxMicro framework does not know how to generate this method";

<#-- -------------------------------------------------------------------------------------------------------- -->
<#else>
<#if RETURN.mono>
return Flux.from(result)
        .map(${ENTITY_CONVERTER}::fromDB)
        .collectList();
<#-- -------------------------------------------------------------------------------------------------------- -->
<#elseif RETURN.flux>
return Flux.from(result)
        .map(${ENTITY_CONVERTER}::fromDB);
<#-- -------------------------------------------------------------------------------------------------------- -->
<#elseif RETURN.future>
return new PublisherToFluxFutureAdapter<>(result)
        .thenApply(l -> l.stream().map(${ENTITY_CONVERTER}::fromDB)
                .collect(Collectors.toList()));
<#-- -------------------------------------------------------------------------------------------------------- -->
<#elseif RETURN.flowable>
return Flowable.fromPublisher(result)
        .map(${ENTITY_CONVERTER}::fromDB);
<#-- -------------------------------------------------------------------------------------------------------- -->
<#elseif RETURN.single>
return Flowable.fromPublisher(result)
        .map(${ENTITY_CONVERTER}::fromDB)
        .collect(ArrayList::new, (l, e) -> l.add(e));
<#-- -------------------------------------------------------------------------------------------------------- -->
<#else>
//"The RxMicro framework does not know how to generate this method";


<#-- -------------------------------------------------------------------------------------------------------- -->




© 2015 - 2024 Weber Informatics LLC | Privacy Policy