---
schema_version: "1"
id: 208780b8e1b6f4f22928666fac77a7a99c909e1ce5078416f88562543c51b6fe
title: onNull
collection: mulesoft
version: current
locale: ja-jp
portal_url: https://docs.salesforce.com/mulesoft/current/ja-jp/dataweave/2.4/dw-core-functions-onnull.md
canonical_url: https://docs.mulesoft.com/jp/dataweave/2.4/dw-core-functions-onnull
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 76de298b56636932936207a1b4faa8c6c655c12eb9cf791c139796297f315f22
description: MuleSoft Documentation Site
release: "2.4"
latest: false
---
# onNull

## [](#onnull1)onNull<R>(previous: Null, callback: () -> R): R

前の式が ​`null`​ 値を返す場合はコールバック関数を実行し、​`null`​ 値をコールバックの結果に置き換えます。

_DataWeave バージョン 2.4.0 で導入されました。_​

### [](#パラメーター)パラメーター

<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 25%;">
<col style="width: 75%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">名前</th>
<th class="tableblock halign-left valign-top">説明</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">​<code>previous</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">前の式の値。</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">​<code>callback</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">​<code>previous</code>​ が ​<code>null</code>​ を返す場合に新しい値を生成するコールバック。</p></td>
</tr>
</tbody>
</table>

### [](#例)例

次の例では、​`null`​ 値を受け取ったときの ​`onNull`​ の動作を示します。

#### [](#ソース)ソース

```DataWeave
%dw 2.0
output application/json
---
{
     "onNull": []
             reduce ((item, accumulator) -> item ++ accumulator)
             then ((result) -> sizeOf(result))
             onNull "Empty Text"
 }
```

#### [](#出力)出力

```Json
{
  "onNull": "Empty Text"
}
```

## [](#onnull2)onNull<T>(previous: T, callback: () -> Any): T

`onNull`​ を​_非 null_​ 値に使用できるようにするヘルパー関数。

_DataWeave バージョン 2.4.0 で導入されました。_​