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

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

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

<#-- -------------------------------------------------------------------------------------------------------- -->
<#-- -------------------------------------------------------------------------------------------------------- -->
<#-- -------------------------------------------------------------------------------------------------------- -->
<#if RETURN.oneItem>
<#if RETURN.mono>
return Mono.from(collection
        .distinct("${FIELD}", <#if QUERY??>query, ${RETURN.simpleResultType}.class));
<#-- -------------------------------------------------------------------------------------------------------- -->
<#elseif RETURN.future>
return new PublisherToFluxFutureAdapter<>(collection
        .distinct("${FIELD}", <#if QUERY??>query, ${RETURN.simpleResultType}.class))
        <#if RETURN.optional>
        .thenApply(l -> l.isEmpty() ? Optional.empty() : Optional.ofNullable(l.get(0)));
        <#else>
        .thenApply(l -> l.get(0));
        
<#-- -------------------------------------------------------------------------------------------------------- -->
<#elseif RETURN.single>
return Single.fromPublisher(collection
        .distinct("${FIELD}", <#if QUERY??>query, ${RETURN.simpleResultType}.class));
<#-- -------------------------------------------------------------------------------------------------------- -->
<#elseif RETURN.maybe>
return Flowable.fromPublisher(collection
        .distinct("${FIELD}", <#if QUERY??>query, ${RETURN.simpleResultType}.class))
        .firstElement();
<#-- -------------------------------------------------------------------------------------------------------- -->
<#else>
//"The RxMicro framework does not know how to generate this method";

<#else>
<#-- -------------------------------------------------------------------------------------------------------- -->
<#if RETURN.mono>
return Flux.from(collection
        .distinct("${FIELD}", <#if QUERY??>query, ${RETURN.simpleResultType}.class))
        .collectList();
<#-- -------------------------------------------------------------------------------------------------------- -->
<#elseif RETURN.flux>
return Flux.from(collection
        .distinct("${FIELD}", <#if QUERY??>query, ${RETURN.simpleResultType}.class));
<#-- -------------------------------------------------------------------------------------------------------- -->
<#elseif RETURN.future>
return new PublisherToFluxFutureAdapter<>(collection
        .distinct("${FIELD}", <#if QUERY??>query, ${RETURN.simpleResultType}.class));
<#-- -------------------------------------------------------------------------------------------------------- -->
<#elseif RETURN.single>
return Flowable.fromPublisher(collection
        .distinct("${FIELD}", <#if QUERY??>query, ${RETURN.simpleResultType}.class))
        .collect(ArrayList::new, (l, e) -> l.add(e));
<#-- -------------------------------------------------------------------------------------------------------- -->
<#elseif RETURN.flowable>
return Flowable.fromPublisher(collection
        .distinct("${FIELD}", <#if QUERY??>query, ${RETURN.simpleResultType}.class));
<#-- -------------------------------------------------------------------------------------------------------- -->
<#else>
//"The RxMicro framework does not know how to generate this method";


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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy