import com.launchdarkly.sdk.LDContext;
import com.launchdarkly.sdk.server.LDClient;
class Test {
public void a() {
LDClient client = new LDClient("sdk-key");
LDContext context = LDContext.builder("context-key")
.name("user")
.build();
boolean flagValue = client.boolVariation("flag-key-123abc", context, false);
if (flagValue) {
// Application code to show the feature
} else {
// The code to run if the feature is off
}
}
}
After:
import com.launchdarkly.sdk.LDContext;
import com.launchdarkly.sdk.server.LDClient;
class Test {
public void a() {
LDClient client = new LDClient("sdk-key");
LDContext context = LDContext.builder("context-key")
/*~~>*/.name("user")
.build();
boolean flagValue = client.boolVariation("flag-key-123abc", context, false);
if (flagValue) {
// Application code to show the feature
} else {
// The code to run if the feature is off
}
}
}
Custom Attribute
Before:
import com.launchdarkly.sdk.LDContext;
import com.launchdarkly.sdk.server.LDClient;
class Test {
public void a() {
LDClient client = new LDClient("sdk-key");
LDContext context = LDContext.builder("context-key")
.name("user")
.set("email", "user@example.com")
.build();
boolean flagValue = client.boolVariation("flag-key-123abc", context, false);
if (flagValue) {
// Application code to show the feature
} else {
// The code to run if the feature is off
}
}
}
After:
import com.launchdarkly.sdk.LDContext;
import com.launchdarkly.sdk.server.LDClient;
class Test {
public void a() {
LDClient client = new LDClient("sdk-key");
LDContext context = LDContext.builder("context-key")
.name("user")
/*~~>*/.set("email", "user@example.com")
.build();
boolean flagValue = client.boolVariation("flag-key-123abc", context, false);
if (flagValue) {
// Application code to show the feature
} else {
// The code to run if the feature is off
}
}
}
Parameters:
Built-in attribute
Before:
After:
Custom Attribute
Before:
After: