mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-05-15 06:58:41 +00:00
docs: update feature toggle
This commit is contained in:
@@ -71,13 +71,18 @@ public class App {
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
|
||||
// Demonstrates the PropertiesFeatureToggleVersion running with properties
|
||||
// that set the feature toggle to enabled.
|
||||
|
||||
final var properties = new Properties();
|
||||
properties.put("enhancedWelcome", true);
|
||||
var service = new PropertiesFeatureToggleVersion(properties);
|
||||
final var welcomeMessage = service.getWelcomeMessage(new User("Jamie No Code"));
|
||||
LOGGER.info(welcomeMessage);
|
||||
|
||||
// ---------------------------------------------
|
||||
// Demonstrates the PropertiesFeatureToggleVersion running with properties
|
||||
// that set the feature toggle to disabled. Note the difference in the printed welcome message
|
||||
// where the username is not included.
|
||||
|
||||
final var turnedOff = new Properties();
|
||||
turnedOff.put("enhancedWelcome", false);
|
||||
@@ -86,7 +91,11 @@ public class App {
|
||||
turnedOffService.getWelcomeMessage(new User("Jamie No Code"));
|
||||
LOGGER.info(welcomeMessageturnedOff);
|
||||
|
||||
// --------------------------------------------
|
||||
// Demonstrates the TieredFeatureToggleVersion setup with
|
||||
// two users: one on the free tier and the other on the paid tier. When the
|
||||
// Service#getWelcomeMessage(User) method is called with the paid user, the welcome
|
||||
// message includes their username. In contrast, calling the same service with the free tier user results
|
||||
// in a more generic welcome message without the username.
|
||||
|
||||
var service2 = new TieredFeatureToggleVersion();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user