growthbook / growthbook-sdk-java

The Java SDK for GrowthBook (JVM, Android)
https://docs.growthbook.io/lib/java
MIT License
7 stars 10 forks source link

evalFeature, run(experiment), callbacks #8

Closed tinahollygb closed 1 year ago

tinahollygb commented 1 year ago

This is a big set of changes that implements necessary code to make feature and run unit tests pass. The test cases are an updated JSON object provided to me to work better with Java.

Context

Adds a Context and builder class to help users build the context, including setting attributes as a JSON string, URL, features as a JSON string, and other relevant properties. The custom builder class implements custom deserialization when setting JSON-related properties both in the builder and when using the setters. A helper static method Context.create has been provided in place of a constructor for developers who prefer to use constructors (e.g. Kotlin with named arguments). It uses the builder in the implementation.

GrowthBook

The main class GrowthBook can be initialized with a Context and can run experiments and evaluate features.

There are still some helper methods that need to be done but the core functionality exists.

JSON

Additional supporting utility methods have been added to the GrowthBookJsonUtils.

More custom serializers and deserializers have been created for FeatureResult, Experiment and ExperimentResult.

ExperimentEvaluator

The experiment evaluation, which supports evalFeature and run(experiment) has been implemented and tested via those public method tests.

JavaDoc

Cleans up the Java Doc, documenting only public methods. All methods, classes, and enum properties are documented. JavaDoc currently returns no warnings.