# Class AssociationRequest.Builder

java.lang.Object
com.codename1.nearby.companion.AssociationRequest.Builder

Enclosing class:
  `AssociationRequest`

public static final class AssociationRequest.Builder extends Object
Assembles an `AssociationRequest`.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `Builder()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `AssociationRequest.Builder`
  `addFilter(DeviceFilter filter)`
  Adds a filter.
  `AssociationRequest`
  `build()`
  Builds the request.
  `AssociationRequest.Builder`
  `profile(CompanionProfile profile)`
  Sets the profile.
  `AssociationRequest.Builder`
  `singleDevice(boolean singleDevice)`
  Asks the platform to skip the chooser when exactly one device matches the filters.

  ### Methods inherited from class Object

  `clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### Builder

    public Builder()

- ## Method Details

  - ### profile

    public AssociationRequest.Builder profile(CompanionProfile profile)

    Sets the profile. Defaults to `CompanionProfile.GENERIC`, which is what most accessories should ask for.

    ###### Parameters

    - `profile`: the profile to request

    ###### Returns

    this builder

  - ### singleDevice

    public AssociationRequest.Builder singleDevice(boolean singleDevice)

    Asks the platform to skip the chooser when exactly one device matches the filters. The user still consents -- they are shown one device and confirm it -- so this is a shortcut, not a way to associate silently.

    ###### Parameters

    - `singleDevice`: whether to take the shortcut

    ###### Returns

    this builder

  - ### addFilter

    public AssociationRequest.Builder addFilter(DeviceFilter filter)

    Adds a filter. Filters are OR-combined.

    ###### Parameters

    - `filter`: the filter to add

    ###### Returns

    this builder

  - ### build

    public AssociationRequest build()

    Builds the request.

    ###### Returns

    the immutable request