Class UserContext.UserContextBuilder
java.lang.Object
growthbook.sdk.java.multiusermode.configurations.UserContext.UserContextBuilder
- Enclosing class:
- UserContext
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionattributes(com.google.gson.JsonObject attributes) attributesJson(String attributesJson) attributesMap(Map<String, ?> attributes) Set attributes from a plainMap, converting it into the internalJsonObjectusing the SDK's shared Gson instance.build()forcedFeatureValues(Map<String, Object> forcedFeatureValues) forcedVariationsMap(Map<String, ?> forcedVariationsMap) stickyBucketAssignmentDocs(Map<String, StickyAssignmentsDocument> stickyBucketAssignmentDocs)
-
Constructor Details
-
UserContextBuilder
public UserContextBuilder()
-
-
Method Details
-
attributesJson
-
attributes
-
attributesMap
Set attributes from a plainMap, converting it into the internalJsonObjectusing the SDK's shared Gson instance. This lets calling code pass attributes without touching the Gson/JSON layer, e.g.UserContext.builder() .attributesMap(Map.of("userId", userId, "country", country)) .build();This is a separate method from
attributes(JsonObject)rather than an overload so that existingattributes(null)calls remain unambiguous.Values should be JSON-compatible: primitives,
String,List, nestedMap, ornull. Other types are serialized via Gson reflection, which is lossy for types such asDateand may fail forjava.timetypes (e.g.Instant) on newer JDKs; convert those to a JSON-compatible value (e.g. an ISO-8601 string) before passing them in.- Parameters:
attributes- attributes as key-value pairs, ornullfor none- Returns:
- this builder
-
url
-
stickyBucketAssignmentDocs
public UserContext.UserContextBuilder stickyBucketAssignmentDocs(Map<String, StickyAssignmentsDocument> stickyBucketAssignmentDocs) -
forcedVariationsMap
-
forcedFeatureValues
-
build
-