---
schema_version: "1"
id: c0f901952e60a07309541c034bf494d9e6ad8511a2f2f87d17d423f6b2f5220b
title: Exclusive Optionals
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/mule-sdk/latest/exclusive-optionals.md
canonical_url: https://docs.mulesoft.com/mule-sdk/latest/exclusive-optionals
source_site: docs.mulesoft.com
content_type: documentation
content_hash: f79f39951098dca41c63d5fcf5106299b4f00a75d12cfa0d953f5269249ea952
description: MuleSoft Documentation Site
release: "1.13"
latest: true
---
---
product: Mule SDK
version: 1.13
is-latest-version: true
keywords: mule, sdk, annotation, exclusive, optional
---

# Exclusive Optionals

> For the full documentation index, see: https://docs.mulesoft.com/llms.txt

When you are developing a module that provides several ways of configuring the same thing, but only
one of them should be used, you might need to set the following rule:

- From a given set of parameters, only one shall be used at any time.

You use `@ExclusiveOptionals` to enforce this restriction.

## @ExclusiveOptionals

The `@ExclusiveOptionals` annotation can only be used on types that are used as a `@ParameterGroup`
(see [Parameters](https://docs.mulesoft.com/mule-sdk/latest/parameters) for details).

Example

```java
@ExclusiveOptionals
public class ExclusiveOptionalsExample {

    @Parameter
    private String requiredParameter;

    @Parameter
    @Optional
    private String optionalParameter;

    @Parameter
    @Optional
    private String anotherOptionalParameter;
}
```

As the name of the annotation implies, the exclusivity restriction only applies to the optional
parameters. So, setting `requiredParameter` at the same time as `optionalParameter` or
`anotherOptionalParameter` is allowed, but setting `optionalParameter` and
`anotherOptionalParameter` at the same time causes an error to be thrown.

Tip: You can have as many parameters as you want inside an object that is annotated with
`@ExclusiveOptionals`, but only one optional parameter is allowed to be set at any time.

## Enforcing At Least One Parameter

There can be cases where exactly one (but no more than one) of the optional parameters must be set.
You can configure this requirement by using `@ExclusiveOptionals(isOneRequired = true)`, for
example:

```java
@ExclusiveOptionals(isOneRequired = true)
public class OneRequiredExample {

    @Parameter
    private String requiredParameter;

    @Parameter
    @Optional
    private String optionalParameter;

    @Parameter
    @Optional
    private String anotherOptionalParameter;
}
```

So, an error is thrown if you set `requiredParameter` but do not set one of the optional parameters:
`optionalParameter` or `anotherOptionalParameter`.
