mirror of https://github.com/open-feature/cli.git
185 lines
6.2 KiB
Plaintext
185 lines
6.2 KiB
Plaintext
// AUTOMATICALLY GENERATED BY OPENFEATURE CLI, DO NOT EDIT.
|
|
package com.example.openfeature;
|
|
|
|
import dev.openfeature.sdk.Client;
|
|
import dev.openfeature.sdk.EvaluationContext;
|
|
import dev.openfeature.sdk.FlagEvaluationDetails;
|
|
import dev.openfeature.sdk.OpenFeatureAPI;
|
|
|
|
public final class OpenFeature {
|
|
|
|
private OpenFeature() {} // prevent instantiation
|
|
|
|
public interface GeneratedClient {
|
|
|
|
/**
|
|
* Discount percentage applied to purchases.
|
|
* Details:
|
|
* - Flag key: discountPercentage
|
|
* - Type: Double
|
|
* - Default value: 0.15
|
|
* Returns the flag value
|
|
*/
|
|
Double discountPercentage(EvaluationContext ctx);
|
|
|
|
/**
|
|
* Discount percentage applied to purchases.
|
|
* Details:
|
|
* - Flag key: discountPercentage
|
|
* - Type: Double
|
|
* - Default value: 0.15
|
|
* Returns the evaluation details containing the flag value and metadata
|
|
*/
|
|
FlagEvaluationDetails<Double> discountPercentageDetails(EvaluationContext ctx);
|
|
|
|
/**
|
|
* Controls whether Feature A is enabled.
|
|
* Details:
|
|
* - Flag key: enableFeatureA
|
|
* - Type: Boolean
|
|
* - Default value: false
|
|
* Returns the flag value
|
|
*/
|
|
Boolean enableFeatureA(EvaluationContext ctx);
|
|
|
|
/**
|
|
* Controls whether Feature A is enabled.
|
|
* Details:
|
|
* - Flag key: enableFeatureA
|
|
* - Type: Boolean
|
|
* - Default value: false
|
|
* Returns the evaluation details containing the flag value and metadata
|
|
*/
|
|
FlagEvaluationDetails<Boolean> enableFeatureADetails(EvaluationContext ctx);
|
|
|
|
/**
|
|
* The message to use for greeting users.
|
|
* Details:
|
|
* - Flag key: greetingMessage
|
|
* - Type: String
|
|
* - Default value: Hello there!
|
|
* Returns the flag value
|
|
*/
|
|
String greetingMessage(EvaluationContext ctx);
|
|
|
|
/**
|
|
* The message to use for greeting users.
|
|
* Details:
|
|
* - Flag key: greetingMessage
|
|
* - Type: String
|
|
* - Default value: Hello there!
|
|
* Returns the evaluation details containing the flag value and metadata
|
|
*/
|
|
FlagEvaluationDetails<String> greetingMessageDetails(EvaluationContext ctx);
|
|
|
|
/**
|
|
* Allows customization of theme colors.
|
|
* Details:
|
|
* - Flag key: themeCustomization
|
|
* - Type: Object
|
|
* - Default value: Map.of("primaryColor", "#007bff", "secondaryColor", "#6c757d")
|
|
* Returns the flag value
|
|
*/
|
|
Object themeCustomization(EvaluationContext ctx);
|
|
|
|
/**
|
|
* Allows customization of theme colors.
|
|
* Details:
|
|
* - Flag key: themeCustomization
|
|
* - Type: Object
|
|
* - Default value: Map.of("primaryColor", "#007bff", "secondaryColor", "#6c757d")
|
|
* Returns the evaluation details containing the flag value and metadata
|
|
*/
|
|
FlagEvaluationDetails<Object> themeCustomizationDetails(EvaluationContext ctx);
|
|
|
|
/**
|
|
* Maximum allowed length for usernames.
|
|
* Details:
|
|
* - Flag key: usernameMaxLength
|
|
* - Type: Integer
|
|
* - Default value: 50
|
|
* Returns the flag value
|
|
*/
|
|
Integer usernameMaxLength(EvaluationContext ctx);
|
|
|
|
/**
|
|
* Maximum allowed length for usernames.
|
|
* Details:
|
|
* - Flag key: usernameMaxLength
|
|
* - Type: Integer
|
|
* - Default value: 50
|
|
* Returns the evaluation details containing the flag value and metadata
|
|
*/
|
|
FlagEvaluationDetails<Integer> usernameMaxLengthDetails(EvaluationContext ctx);
|
|
|
|
}
|
|
|
|
private static final class OpenFeatureGeneratedClient implements GeneratedClient {
|
|
private final Client client;
|
|
|
|
private OpenFeatureGeneratedClient(Client client) {
|
|
this.client = client;
|
|
}
|
|
|
|
|
|
@Override
|
|
public Double discountPercentage(EvaluationContext ctx) {
|
|
return client.getDoubleValue("discountPercentage", 0.15, ctx);
|
|
}
|
|
|
|
@Override
|
|
public FlagEvaluationDetails<Double> discountPercentageDetails(EvaluationContext ctx) {
|
|
return client.getDoubleDetails("discountPercentage", 0.15, ctx);
|
|
}
|
|
|
|
@Override
|
|
public Boolean enableFeatureA(EvaluationContext ctx) {
|
|
return client.getBooleanValue("enableFeatureA", false, ctx);
|
|
}
|
|
|
|
@Override
|
|
public FlagEvaluationDetails<Boolean> enableFeatureADetails(EvaluationContext ctx) {
|
|
return client.getBooleanDetails("enableFeatureA", false, ctx);
|
|
}
|
|
|
|
@Override
|
|
public String greetingMessage(EvaluationContext ctx) {
|
|
return client.getStringValue("greetingMessage", "Hello there!", ctx);
|
|
}
|
|
|
|
@Override
|
|
public FlagEvaluationDetails<String> greetingMessageDetails(EvaluationContext ctx) {
|
|
return client.getStringDetails("greetingMessage", "Hello there!", ctx);
|
|
}
|
|
|
|
@Override
|
|
public Object themeCustomization(EvaluationContext ctx) {
|
|
return client.getObjectValue("themeCustomization", Map.of("primaryColor", "#007bff", "secondaryColor", "#6c757d"), ctx);
|
|
}
|
|
|
|
@Override
|
|
public FlagEvaluationDetails<Object> themeCustomizationDetails(EvaluationContext ctx) {
|
|
return client.getObjectDetails("themeCustomization", Map.of("primaryColor", "#007bff", "secondaryColor", "#6c757d"), ctx);
|
|
}
|
|
|
|
@Override
|
|
public Integer usernameMaxLength(EvaluationContext ctx) {
|
|
return client.getIntegerValue("usernameMaxLength", 50, ctx);
|
|
}
|
|
|
|
@Override
|
|
public FlagEvaluationDetails<Integer> usernameMaxLengthDetails(EvaluationContext ctx) {
|
|
return client.getIntegerDetails("usernameMaxLength", 50, ctx);
|
|
}
|
|
|
|
}
|
|
|
|
public static GeneratedClient getClient() {
|
|
return new OpenFeatureGeneratedClient(OpenFeatureAPI.getInstance().getClient());
|
|
}
|
|
|
|
public static GeneratedClient getClient(String domain) {
|
|
return new OpenFeatureGeneratedClient(OpenFeatureAPI.getInstance().getClient(domain));
|
|
}
|
|
}
|