Suchen

Dieser Inhalt ist in der von Ihnen ausgewählten Sprache nicht verfügbar.

56.4. Nullable Options

download PDF

Overview

In some cases, it can make sense to let method arguments default to null. But this is not allowed by default. If you want to allow some of your method arguments from the Java API to take null values, you must declare this explicitly using the nullableOptions element.

Syntax

The nullableOptions element can be defined with one or more nullableOption child elements, as follows:
<nullableOptions>
  <nullableOption>ArgumentName</nullableOption>
  ...
</nullableOptions>
Where ArgumentName is the name of a method argument from the Java API.

Scope

As shown in the following extract, the nullableOptions element can optionally appear as a child of the apis element and/or as a child of api elements:
<configuration>
  <apis>
    <api>
      <apiName>...</apiName>
      ...
 <nullableOptions>...</nullableOptions>
    </api>
    ...
 <nullableOptions>...</nullableOptions>
  </apis>
</configuration>
You can define the nullableOptions element at the following scopes:
  • As a child of an api element—the nullableOptions mappings apply only to the API class specified by the api element.
  • As a child of the apis element—the nullableOptions mappings apply to all API classes by default, but can be overridden at the api level.

Example

The following example shows the nullable options declared for the CompaniesResource proxy class from the Apache Camel LinkedIn component:
<nullableOptions>
  <nullableOption>companySizes</nullableOption>
  <nullableOption>count</nullableOption>
  <nullableOption>email_domain</nullableOption>
  <nullableOption>end_timestamp</nullableOption>
  <nullableOption>event_type</nullableOption>
  <nullableOption>geos</nullableOption>
  <nullableOption>industries</nullableOption>
  <nullableOption>is_company_admin</nullableOption>
  <nullableOption>jobFunc</nullableOption>
  <nullableOption>secure_urls</nullableOption>
  <nullableOption>seniorities</nullableOption>
  <nullableOption>start</nullableOption>
  <nullableOption>start_timestamp</nullableOption>
  <nullableOption>statistics_update_key</nullableOption>
  <nullableOption>time_granularity</nullableOption>
</nullableOptions>
Red Hat logoGithubRedditYoutubeTwitter

Lernen

Testen, kaufen und verkaufen

Communitys

Über Red Hat Dokumentation

Wir helfen Red Hat Benutzern, mit unseren Produkten und Diensten innovativ zu sein und ihre Ziele zu erreichen – mit Inhalten, denen sie vertrauen können.

Mehr Inklusion in Open Source

Red Hat hat sich verpflichtet, problematische Sprache in unserem Code, unserer Dokumentation und unseren Web-Eigenschaften zu ersetzen. Weitere Einzelheiten finden Sie in Red Hat Blog.

Über Red Hat

Wir liefern gehärtete Lösungen, die es Unternehmen leichter machen, plattform- und umgebungsübergreifend zu arbeiten, vom zentralen Rechenzentrum bis zum Netzwerkrand.

© 2024 Red Hat, Inc.