Created
July 24, 2019 23:52
-
-
Save levlaz/529a4b98c072eb8000532952ffce739d to your computer and use it in GitHub Desktop.
Java Relay Snippet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.launchdarkly.client.LDClient; | |
import com.launchdarkly.client.LDConfig; | |
import com.launchdarkly.client.LDUser; | |
import java.io.IOException; | |
import java.net.URI; | |
import java.net.URISyntaxException; | |
import static java.util.Collections.singletonList; | |
public class Hello { | |
public static void main(String... args) throws IOException, URISyntaxException { | |
URI streamURI = new URI("https://app.relay.com"); | |
LDConfig config = new LDConfig.Builder() | |
.streamURI(streamURI) | |
.build(); | |
LDClient client = new LDClient("YOUR_SDK_KEY", config); | |
LDUser user = new LDUser.Builder("[email protected]") | |
.firstName("Bob") | |
.lastName("Loblaw") | |
.customString("groups", singletonList("beta_testers")) | |
.build(); | |
boolean showFeature = client.boolVariation("YOUR_FEATURE_KEY", user, false); | |
if (showFeature) { | |
System.out.println("Showing your feature"); | |
} else { | |
System.out.println("Not showing your feature"); | |
} | |
client.flush(); | |
client.close(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment