Skip to content

Instantly share code, notes, and snippets.

@levlaz
Created April 17, 2018 11:07
Show Gist options
  • Save levlaz/51f667dc700f4630e4cb1b9145c0f71a to your computer and use it in GitHub Desktop.
Save levlaz/51f667dc700f4630e4cb1b9145c0f71a to your computer and use it in GitHub Desktop.
Java Sample Code
import com.launchdarkly.client.*;
LDClient ldClient = new LDClient("YOUR_SDK_KEY");
LDUser user = new LDUser.Builder("some_id")
// // 100% Optional
.firstName("Ernestina")
.lastName("Evans")
.email("[email protected]")
// Any arbitrary custom metadata can be passed along
.custom("groups", Arrays.asList("VIP")
.custom("country", Arrays.asList("UK"))
.custom("plan", Arrays.asList("silver"))
.custom("MRR", 500)
.custom("SignUpDate", "1/1/2017")
.custom("version", 11)
.build()
boolean showFeature = ldClient.boolVariation(
"beta-ui",
user,
false
);
if (showFeature) {
// application code to show the feature
newCode()
}
else {
oldCode()
// the code to run if the featnew-checkout-flowure is off
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment