Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class LogicFactory {
- // Check for test mode
- private static boolean isTestMode = false;
- private static boolean canChangeMode = true;
- private LogicFactory(){
- // Empty constructor for readability. Class will only contain static methods
- }
- public static void setTestMode(boolean isTestMode){
- if(LogicFactory.canChangeMode) {
- LogicFactory.isTestMode = isTestMode;
- canChangeMode = false;
- }
- else
- throw new IllegalStateException("Logic factory state already has been defined and can only be defined once");
- }
- public static IMessageCreator createMessageCreator(){
- if(isTestMode)
- return new MessageCreatorMock();
- else
- return new MessageCreator();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement