Package growthbook.sdk.java.model
Class TypedKey<T>
java.lang.Object
growthbook.sdk.java.model.TypedKey<T>
- Type Parameters:
T- the value type the feature evaluates to
- All Implemented Interfaces:
FeatureKey<T>
Default immutable implementation of
FeatureKey.
Declare feature keys as constants and reference them wherever a feature is evaluated:
public final class Features {
public static final TypedKey<Boolean> NEW_HOME = TypedKey.ofBoolean("new-home");
public static final TypedKey<String> THEME = TypedKey.ofString("theme");
public static final TypedKey<Integer> MAX_ITEMS = TypedKey.ofInteger("max-items");
public static final TypedKey<MyConfig> CONFIG = TypedKey.of("my-config", MyConfig.class);
private Features() {}
}
-
Method Summary
Modifier and TypeMethodDescriptionbooleangetKey()The feature identifier as configured in GrowthBook, e.g.The Gson-deserializable class of the feature value, e.g.inthashCode()static <T> TypedKey<T>Creates a typed key for an arbitrary Gson-deserializable value type.Creates a typed key for a boolean feature.Creates a typed key for a double feature.Creates a typed key for a float feature.Creates a typed key for an integer feature.Creates a typed key for a string feature.toString()
-
Method Details
-
of
Creates a typed key for an arbitrary Gson-deserializable value type.- Type Parameters:
T- the value type- Parameters:
key- the feature identifiervalueType- the value type class, e.g.MyConfig.class- Returns:
- a new typed key
-
ofBoolean
Creates a typed key for a boolean feature.- Parameters:
key- the feature identifier- Returns:
- a new typed key
-
ofString
Creates a typed key for a string feature.- Parameters:
key- the feature identifier- Returns:
- a new typed key
-
ofInteger
Creates a typed key for an integer feature.- Parameters:
key- the feature identifier- Returns:
- a new typed key
-
ofDouble
Creates a typed key for a double feature.- Parameters:
key- the feature identifier- Returns:
- a new typed key
-
ofFloat
Creates a typed key for a float feature.- Parameters:
key- the feature identifier- Returns:
- a new typed key
-
getKey
Description copied from interface:FeatureKeyThe feature identifier as configured in GrowthBook, e.g."new-home".- Specified by:
getKeyin interfaceFeatureKey<T>- Returns:
- the raw feature key
-
getValueType
Description copied from interface:FeatureKeyThe Gson-deserializable class of the feature value, e.g.Boolean.class.- Specified by:
getValueTypein interfaceFeatureKey<T>- Returns:
- the value type
-
equals
-
hashCode
public int hashCode() -
toString
-