📍Use lombok, reformat, and optimize the code (#1560)
* Use lombok, reformat, and optimize the code * Fix merge conflicts and some sonar issues Co-authored-by: va1m <va1m@email.com>
This commit is contained in:
@@ -29,8 +29,7 @@ import com.iluwatar.featuretoggle.pattern.tieredversion.TieredFeatureToggleVersi
|
||||
import com.iluwatar.featuretoggle.user.User;
|
||||
import com.iluwatar.featuretoggle.user.UserGroup;
|
||||
import java.util.Properties;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* The Feature Toggle pattern allows for complete code executions to be turned on or off with ease.
|
||||
@@ -45,10 +44,9 @@ import org.slf4j.LoggerFactory;
|
||||
* <p>Note that this pattern can easily introduce code complexity, and if not kept in check can
|
||||
* result in redundant unmaintained code within the codebase.
|
||||
*/
|
||||
@Slf4j
|
||||
public class App {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(App.class);
|
||||
|
||||
/**
|
||||
* Block 1 shows the {@link PropertiesFeatureToggleVersion} being run with {@link Properties}
|
||||
* setting the feature toggle to enabled.
|
||||
|
@@ -26,6 +26,7 @@ package com.iluwatar.featuretoggle.pattern.propertiesversion;
|
||||
import com.iluwatar.featuretoggle.pattern.Service;
|
||||
import com.iluwatar.featuretoggle.user.User;
|
||||
import java.util.Properties;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* This example of the Feature Toogle pattern is less dynamic version than {@link
|
||||
@@ -40,9 +41,15 @@ import java.util.Properties;
|
||||
* @see com.iluwatar.featuretoggle.pattern.tieredversion.TieredFeatureToggleVersion
|
||||
* @see User
|
||||
*/
|
||||
@Getter
|
||||
public class PropertiesFeatureToggleVersion implements Service {
|
||||
|
||||
private final boolean isEnhanced;
|
||||
/**
|
||||
* True if the welcome message to be returned is the enhanced venison or not. For
|
||||
* this service it will see the value of the boolean that was set in the constructor {@link
|
||||
* PropertiesFeatureToggleVersion#PropertiesFeatureToggleVersion(Properties)}
|
||||
*/
|
||||
private final boolean enhanced;
|
||||
|
||||
/**
|
||||
* Creates an instance of {@link PropertiesFeatureToggleVersion} using the passed {@link
|
||||
@@ -59,7 +66,7 @@ public class PropertiesFeatureToggleVersion implements Service {
|
||||
throw new IllegalArgumentException("No Properties Provided.");
|
||||
} else {
|
||||
try {
|
||||
isEnhanced = (boolean) properties.get("enhancedWelcome");
|
||||
enhanced = (boolean) properties.get("enhancedWelcome");
|
||||
} catch (Exception e) {
|
||||
throw new IllegalArgumentException("Invalid Enhancement Settings Provided.");
|
||||
}
|
||||
@@ -87,16 +94,4 @@ public class PropertiesFeatureToggleVersion implements Service {
|
||||
|
||||
return "Welcome to the application.";
|
||||
}
|
||||
|
||||
/**
|
||||
* Method that checks if the welcome message to be returned is the enhanced venison or not. For
|
||||
* this service it will see the value of the boolean that was set in the constructor {@link
|
||||
* PropertiesFeatureToggleVersion#PropertiesFeatureToggleVersion(Properties)}
|
||||
*
|
||||
* @return Boolean value {@code true} if enhanced.
|
||||
*/
|
||||
@Override
|
||||
public boolean isEnhanced() {
|
||||
return isEnhanced;
|
||||
}
|
||||
}
|
||||
|
@@ -23,23 +23,17 @@
|
||||
|
||||
package com.iluwatar.featuretoggle.user;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
/**
|
||||
* Used to demonstrate the purpose of the feature toggle. This class actually has nothing to do with
|
||||
* the pattern.
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
public class User {
|
||||
|
||||
private final String name;
|
||||
|
||||
/**
|
||||
* Default Constructor setting the username.
|
||||
*
|
||||
* @param name {@link String} to represent the name of the user.
|
||||
*/
|
||||
public User(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
|
@@ -38,7 +38,6 @@ public class UserGroup {
|
||||
private static final List<User> freeGroup = new ArrayList<>();
|
||||
private static final List<User> paidGroup = new ArrayList<>();
|
||||
|
||||
|
||||
/**
|
||||
* Add the passed {@link User} to the free user group list.
|
||||
*
|
||||
|
Reference in New Issue
Block a user