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

ftl.data.mongo.mongo-libftl Maven / Gradle / Ivy

There is a newer version: 0.11
Show newest version
<#-- ------------------------------------------------------------------------------------------------ -->
<#-- ---------------- https://freemarker.apache.org/docs/ref_directive_function.html ---------------- -->
<#-- ------------------------------------------------------------------------------------------------ -->
<#function createBsonVar VAR EXP>
<#assign VALUE>
<#list EXP.lines as line>
${line}


<#assign RESULT>
<#if SHOW_ORIGINAL_QUERY>
// ${VAR} = "${EXP.originalExpression}

final Document ${VAR} = ${VALUE?trim}

<#return RESULT?trim>

<#-- ------------------------------------------------------------------------------------------------ -->
<#-- ----------------- https://freemarker.apache.org/docs/ref_directive_macro.html ------------------ -->
<#-- ------------------------------------------------------------------------------------------------ -->
<#macro returnUpdateResult>
    <@returnResult 'getModifiedCount'/>

<#-- ------------------------------------------------------------------------------------------------ -->
<#-- ----------------- https://freemarker.apache.org/docs/ref_directive_macro.html ------------------ -->
<#-- ------------------------------------------------------------------------------------------------ -->
<#macro returnDeleteResult>
    <@returnResult 'getDeletedCount'/>

<#-- ------------------------------------------------------------------------------------------------ -->
<#-- ----------------- https://freemarker.apache.org/docs/ref_directive_macro.html ------------------ -->
<#-- ------------------------------------------------------------------------------------------------ -->
<#macro returnResult longResultMethod>
<#-- ------------------------------------------------------------------------------------------------ -->
<#if RETURN.mono>
<#if RETURN.void>
return Mono.from(result).then();
<#elseif RETURN.long>
return Mono.from(result)
        .map(r -> r.${longResultMethod}());
<#elseif RETURN.boolean>
return Mono.from(result)
        .map(r -> r.${longResultMethod}() == 1);
<#else>
return Mono.from(result);

<#-- ------------------------------------------------------------------------------------------------ -->
<#elseif RETURN.completable>
return Completable.fromPublisher(result);
<#-- ------------------------------------------------------------------------------------------------ -->
<#elseif RETURN.single>
<#if RETURN.long>
return Single.fromPublisher(result)
        .map(r -> r.${longResultMethod}());
<#elseif RETURN.boolean>
return Single.fromPublisher(result)
        .map(r -> r.${longResultMethod}() == 1);
<#else>
return Single.fromPublisher(result);

<#-- ------------------------------------------------------------------------------------------------ -->
<#elseif RETURN.future>
<#if RETURN.void>
return new PublisherToRequiredMonoFutureAdapter<>(
        result,
        useOptionalExceptionSupplier(${RETURN.simpleReactiveType}.class, ${RETURN.simpleResultType}.class)
).thenApply(r -> null);
<#elseif RETURN.boolean>
return new PublisherToRequiredMonoFutureAdapter<>(
        result,
        useOptionalExceptionSupplier(${RETURN.simpleReactiveType}.class, ${RETURN.simpleResultType}.class)
).thenApply(r -> r.${longResultMethod}() == 1);
<#elseif RETURN.long>
return new PublisherToRequiredMonoFutureAdapter<>(
        result,
        useOptionalExceptionSupplier(${RETURN.simpleReactiveType}.class, ${RETURN.simpleResultType}.class)
).thenApply(r -> r.${longResultMethod}());
<#else>
return new PublisherToRequiredMonoFutureAdapter<>(
        result,
        useOptionalExceptionSupplier(${RETURN.simpleReactiveType}.class, ${RETURN.simpleResultType}.class)
);


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

<#-- ------------------------------------------------------------------------------------------------ -->
<#-- ----------------- https://freemarker.apache.org/docs/ref_directive_macro.html ------------------ -->
<#-- ------------------------------------------------------------------------------------------------ -->




© 2015 - 2025 Weber Informatics LLC | Privacy Policy