Class LDUser.Builder

java.lang.Object
com.launchdarkly.sdk.LDUser.Builder
Enclosing class:
LDUser

public static class LDUser.Builder
extends java.lang.Object
A builder that helps construct LDUser objects. Builder calls can be chained, enabling the following pattern:
 LDUser user = new LDUser.Builder("key")
      .country("US")
      .ip("192.168.0.1")
      .build()
 
  • Constructor Summary

    Constructors 
    Constructor Description
    Builder​(LDUser user)
    Creates a builder based on an existing user.
    Builder​(java.lang.String key)
    Creates a builder with the specified key.
  • Method Summary

    Modifier and Type Method Description
    LDUser.Builder anonymous​(boolean anonymous)
    Sets whether this user is anonymous.
    LDUser.Builder avatar​(java.lang.String avatar)
    Sets the user's avatar.
    LDUser build()
    Builds the configured LDUser object.
    LDUser.Builder country​(java.lang.String s)
    Set the country for a user.
    LDUser.Builder custom​(java.lang.String k, boolean b)
    Add a boolean-valued custom attribute.
    LDUser.Builder custom​(java.lang.String k, double n)
    Adds a double-precision numeric custom attribute.
    LDUser.Builder custom​(java.lang.String k, int n)
    Adds an integer-valued custom attribute.
    LDUser.Builder custom​(java.lang.String k, LDValue v)
    Add a custom attribute whose value can be any JSON type, using LDValue.
    LDUser.Builder custom​(java.lang.String k, java.lang.String v)
    Adds a String-valued custom attribute.
    LDUser.Builder email​(java.lang.String email)
    Sets the user's e-mail address.
    LDUser.Builder firstName​(java.lang.String firstName)
    Sets the user's first name
    LDUser.Builder ip​(java.lang.String s)
    Sets the IP for a user.
    LDUser.Builder key​(java.lang.String s)
    Changes the user's key.
    LDUser.Builder lastName​(java.lang.String lastName)
    Sets the user's last name.
    LDUser.Builder name​(java.lang.String name)
    Sets the user's full name.
    LDUser.Builder privateAvatar​(java.lang.String avatar)
    Sets the user's avatar, and ensures that the avatar attribute will not be sent back to LaunchDarkly.
    LDUser.Builder privateCountry​(java.lang.String s)
    Set the country for a user, and ensures that the country attribute will not be sent back to LaunchDarkly.
    LDUser.Builder privateCustom​(java.lang.String k, boolean b)
    Add a boolean-valued custom attribute that will not be sent back to LaunchDarkly.
    LDUser.Builder privateCustom​(java.lang.String k, double n)
    Add a double-precision numeric custom attribute that will not be sent back to LaunchDarkly.
    LDUser.Builder privateCustom​(java.lang.String k, int n)
    Add an int-valued custom attribute that will not be sent back to LaunchDarkly.
    LDUser.Builder privateCustom​(java.lang.String k, LDValue v)
    Add a custom attribute of any JSON type, that will not be sent back to LaunchDarkly.
    LDUser.Builder privateCustom​(java.lang.String k, java.lang.String v)
    Add a String-valued custom attribute that will not be sent back to LaunchDarkly.
    LDUser.Builder privateEmail​(java.lang.String email)
    Sets the user's e-mail address, and ensures that the e-mail address attribute will not be sent back to LaunchDarkly.
    LDUser.Builder privateFirstName​(java.lang.String firstName)
    Sets the user's first name, and ensures that the first name attribute will not be sent back to LaunchDarkly.
    LDUser.Builder privateIp​(java.lang.String s)
    Sets the IP for a user, and ensures that the IP attribute is not sent back to LaunchDarkly.
    LDUser.Builder privateLastName​(java.lang.String lastName)
    Sets the user's last name, and ensures that the last name attribute will not be sent back to LaunchDarkly.
    LDUser.Builder privateName​(java.lang.String name)
    Sets the user's full name, and ensures that the name attribute will not be sent back to LaunchDarkly.
    LDUser.Builder privateSecondary​(java.lang.String s)
    Sets the secondary key for a user, and ensures that the secondary key attribute is not sent back to LaunchDarkly.
    LDUser.Builder secondary​(java.lang.String s)
    Sets the secondary key for a user.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Builder

      public Builder​(java.lang.String key)
      Creates a builder with the specified key.
      Parameters:
      key - the unique key for this user
    • Builder

      public Builder​(LDUser user)
      Creates a builder based on an existing user.
      Parameters:
      user - an existing LDUser
  • Method Details

    • key

      public LDUser.Builder key​(java.lang.String s)
      Changes the user's key.
      Parameters:
      s - the user key
      Returns:
      the builder
    • ip

      public LDUser.Builder ip​(java.lang.String s)
      Sets the IP for a user.
      Parameters:
      s - the IP address for the user
      Returns:
      the builder
    • privateIp

      public LDUser.Builder privateIp​(java.lang.String s)
      Sets the IP for a user, and ensures that the IP attribute is not sent back to LaunchDarkly.
      Parameters:
      s - the IP address for the user
      Returns:
      the builder
    • secondary

      public LDUser.Builder secondary​(java.lang.String s)
      Sets the secondary key for a user. This affects feature flag targeting as follows: if you have chosen to bucket users by a specific attribute, the secondary key (if set) is used to further distinguish between users who are otherwise identical according to that attribute.
      Parameters:
      s - the secondary key for the user
      Returns:
      the builder
    • privateSecondary

      public LDUser.Builder privateSecondary​(java.lang.String s)
      Sets the secondary key for a user, and ensures that the secondary key attribute is not sent back to LaunchDarkly.
      Parameters:
      s - the secondary key for the user
      Returns:
      the builder
    • country

      public LDUser.Builder country​(java.lang.String s)
      Set the country for a user. Before version 5.0.0, this field was validated and normalized by the SDK as an ISO-3166-1 country code before assignment. This behavior has been removed so that the SDK can treat this field as a normal string, leaving the meaning of this field up to the application.
      Parameters:
      s - the country for the user
      Returns:
      the builder
    • privateCountry

      public LDUser.Builder privateCountry​(java.lang.String s)
      Set the country for a user, and ensures that the country attribute will not be sent back to LaunchDarkly. Before version 5.0.0, this field was validated and normalized by the SDK as an ISO-3166-1 country code before assignment. This behavior has been removed so that the SDK can treat this field as a normal string, leaving the meaning of this field up to the application.
      Parameters:
      s - the country for the user
      Returns:
      the builder
    • firstName

      public LDUser.Builder firstName​(java.lang.String firstName)
      Sets the user's first name
      Parameters:
      firstName - the user's first name
      Returns:
      the builder
    • privateFirstName

      public LDUser.Builder privateFirstName​(java.lang.String firstName)
      Sets the user's first name, and ensures that the first name attribute will not be sent back to LaunchDarkly.
      Parameters:
      firstName - the user's first name
      Returns:
      the builder
    • anonymous

      public LDUser.Builder anonymous​(boolean anonymous)
      Sets whether this user is anonymous.
      Parameters:
      anonymous - whether the user is anonymous
      Returns:
      the builder
    • lastName

      public LDUser.Builder lastName​(java.lang.String lastName)
      Sets the user's last name.
      Parameters:
      lastName - the user's last name
      Returns:
      the builder
    • privateLastName

      public LDUser.Builder privateLastName​(java.lang.String lastName)
      Sets the user's last name, and ensures that the last name attribute will not be sent back to LaunchDarkly.
      Parameters:
      lastName - the user's last name
      Returns:
      the builder
    • name

      public LDUser.Builder name​(java.lang.String name)
      Sets the user's full name.
      Parameters:
      name - the user's full name
      Returns:
      the builder
    • privateName

      public LDUser.Builder privateName​(java.lang.String name)
      Sets the user's full name, and ensures that the name attribute will not be sent back to LaunchDarkly.
      Parameters:
      name - the user's full name
      Returns:
      the builder
    • avatar

      public LDUser.Builder avatar​(java.lang.String avatar)
      Sets the user's avatar.
      Parameters:
      avatar - the user's avatar
      Returns:
      the builder
    • privateAvatar

      public LDUser.Builder privateAvatar​(java.lang.String avatar)
      Sets the user's avatar, and ensures that the avatar attribute will not be sent back to LaunchDarkly.
      Parameters:
      avatar - the user's avatar
      Returns:
      the builder
    • email

      public LDUser.Builder email​(java.lang.String email)
      Sets the user's e-mail address.
      Parameters:
      email - the e-mail address
      Returns:
      the builder
    • privateEmail

      public LDUser.Builder privateEmail​(java.lang.String email)
      Sets the user's e-mail address, and ensures that the e-mail address attribute will not be sent back to LaunchDarkly.
      Parameters:
      email - the e-mail address
      Returns:
      the builder
    • custom

      public LDUser.Builder custom​(java.lang.String k, java.lang.String v)
      Adds a String-valued custom attribute. When set to one of the built-in user attribute keys, this custom attribute will be ignored.
      Parameters:
      k - the key for the custom attribute
      v - the value for the custom attribute
      Returns:
      the builder
    • custom

      public LDUser.Builder custom​(java.lang.String k, int n)
      Adds an integer-valued custom attribute. When set to one of the built-in user attribute keys, this custom attribute will be ignored.
      Parameters:
      k - the key for the custom attribute
      n - the value for the custom attribute
      Returns:
      the builder
    • custom

      public LDUser.Builder custom​(java.lang.String k, double n)
      Adds a double-precision numeric custom attribute. When set to one of the built-in user attribute keys, this custom attribute will be ignored.
      Parameters:
      k - the key for the custom attribute
      n - the value for the custom attribute
      Returns:
      the builder
    • custom

      public LDUser.Builder custom​(java.lang.String k, boolean b)
      Add a boolean-valued custom attribute. When set to one of the built-in user attribute keys, this custom attribute will be ignored.
      Parameters:
      k - the key for the custom attribute
      b - the value for the custom attribute
      Returns:
      the builder
    • custom

      public LDUser.Builder custom​(java.lang.String k, LDValue v)
      Add a custom attribute whose value can be any JSON type, using LDValue. When set to one of the built-in user attribute keys, this custom attribute will be ignored.
      Parameters:
      k - the key for the custom attribute
      v - the value for the custom attribute
      Returns:
      the builder
    • privateCustom

      public LDUser.Builder privateCustom​(java.lang.String k, java.lang.String v)
      Add a String-valued custom attribute that will not be sent back to LaunchDarkly. When set to one of the built-in user attribute keys, this custom attribute will be ignored.
      Parameters:
      k - the key for the custom attribute
      v - the value for the custom attribute
      Returns:
      the builder
    • privateCustom

      public LDUser.Builder privateCustom​(java.lang.String k, int n)
      Add an int-valued custom attribute that will not be sent back to LaunchDarkly. When set to one of the built-in user attribute keys, this custom attribute will be ignored.
      Parameters:
      k - the key for the custom attribute
      n - the value for the custom attribute
      Returns:
      the builder
    • privateCustom

      public LDUser.Builder privateCustom​(java.lang.String k, double n)
      Add a double-precision numeric custom attribute that will not be sent back to LaunchDarkly. When set to one of the built-in user attribute keys, this custom attribute will be ignored.
      Parameters:
      k - the key for the custom attribute
      n - the value for the custom attribute
      Returns:
      the builder
    • privateCustom

      public LDUser.Builder privateCustom​(java.lang.String k, boolean b)
      Add a boolean-valued custom attribute that will not be sent back to LaunchDarkly. When set to one of the built-in user attribute keys, this custom attribute will be ignored.
      Parameters:
      k - the key for the custom attribute
      b - the value for the custom attribute
      Returns:
      the builder
    • privateCustom

      public LDUser.Builder privateCustom​(java.lang.String k, LDValue v)
      Add a custom attribute of any JSON type, that will not be sent back to LaunchDarkly. When set to one of the built-in user attribute keys, this custom attribute will be ignored.
      Parameters:
      k - the key for the custom attribute
      v - the value for the custom attribute
      Returns:
      the builder
    • build

      public LDUser build()
      Builds the configured LDUser object.
      Returns:
      the LDUser configured by this builder