Skip to content

Commit bf5ba44

Browse files
committed
iluwatar#354 add App.java
1 parent 7cc93de commit bf5ba44

1 file changed

Lines changed: 65 additions & 0 deletions

File tree

  • feature-toggle/src/main/java/com/iluwatar/featuretoggle
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/**
2+
* The MIT License
3+
* Copyright (c) 2014 Ilkka Seppälä
4+
*
5+
* Permission is hereby granted, free of charge, to any person obtaining a copy
6+
* of this software and associated documentation files (the "Software"), to deal
7+
* in the Software without restriction, including without limitation the rights
8+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
* copies of the Software, and to permit persons to whom the Software is
10+
* furnished to do so, subject to the following conditions:
11+
*
12+
* The above copyright notice and this permission notice shall be included in
13+
* all copies or substantial portions of the Software.
14+
*
15+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
* THE SOFTWARE.
22+
*/
23+
24+
package com.iluwatar.featuretoggle;
25+
26+
import com.iluwatar.featuretoggle.pattern.Service;
27+
import com.iluwatar.featuretoggle.pattern.propertiesversion.PropertiesFeatureToggleVersion;
28+
import com.iluwatar.featuretoggle.user.User;
29+
import com.iluwatar.featuretoggle.user.UserGroup;
30+
31+
import java.util.Properties;
32+
33+
/**
34+
*
35+
*/
36+
public class App {
37+
38+
/**
39+
*
40+
*/
41+
public static void main(String[] args) {
42+
final Properties properties = new Properties();
43+
properties.put("enhancedWelcome", true);
44+
Service service = new PropertiesFeatureToggleVersion(properties);
45+
final String welcomeMessage = service.getWelcomeMessage(new User("Jamie No Code"));
46+
System.out.println(welcomeMessage);
47+
48+
final Properties turnedOff = new Properties();
49+
turnedOff.put("enhancedWelcome", false);
50+
Service turnedOffService = new PropertiesFeatureToggleVersion(turnedOff);
51+
final String welcomeMessageturnedOff = turnedOffService.getWelcomeMessage(new User("Jamie No Code"));
52+
System.out.println(welcomeMessageturnedOff);
53+
54+
final User paidUser = new User("Jamie Coder");
55+
final User freeUser = new User("Alan Defect");
56+
57+
UserGroup.addUserToPaidGroup(paidUser);
58+
UserGroup.addUserToFreeGroup(freeUser);
59+
60+
final String welcomeMessagePaidUser = service.getWelcomeMessage(paidUser);
61+
final String welcomeMessageFreeUser = service.getWelcomeMessage(freeUser);
62+
System.out.println(welcomeMessageFreeUser);
63+
System.out.println(welcomeMessagePaidUser);
64+
}
65+
}

0 commit comments

Comments
 (0)