#354 Fixed CheckStyle Issues
This commit is contained in:
@ -5,6 +5,6 @@ import com.iluwatar.featuretoggle.user.User;
|
||||
|
||||
public interface Service {
|
||||
|
||||
String getWelcomeMessage(User user);
|
||||
String getWelcomeMessage(User user);
|
||||
|
||||
}
|
||||
|
@ -6,13 +6,13 @@ import com.iluwatar.featuretoggle.user.UserGroup;
|
||||
|
||||
public class TieredFeatureToggleVersion implements Service {
|
||||
|
||||
@Override
|
||||
public String getWelcomeMessage(User user) {
|
||||
if(UserGroup.isPaid(user)){
|
||||
return "You're amazing " + user.getName() + ". Thanks for paying for this awesome software.";
|
||||
}
|
||||
|
||||
return "I suppose you can use this software.";
|
||||
@Override
|
||||
public String getWelcomeMessage(User user) {
|
||||
if (UserGroup.isPaid(user)) {
|
||||
return "You're amazing " + user.getName() + ". Thanks for paying for this awesome software.";
|
||||
}
|
||||
|
||||
return "I suppose you can use this software.";
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,13 +2,13 @@ package com.iluwatar.featuretoggle.user;
|
||||
|
||||
public class User {
|
||||
|
||||
private String name;
|
||||
private String name;
|
||||
|
||||
public User(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
public User(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
@ -3,32 +3,43 @@ package com.iluwatar.featuretoggle.user;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Contains the lists of users of different groups paid and free
|
||||
*/
|
||||
public class UserGroup {
|
||||
|
||||
private static List<User> freeGroup = new ArrayList<>();
|
||||
private static List<User> paidGroup = new ArrayList<>();
|
||||
private static List<User> freeGroup = new ArrayList<>();
|
||||
private static List<User> paidGroup = new ArrayList<>();
|
||||
|
||||
public static void addUserToFreeGroup(final User user){
|
||||
if(paidGroup.contains(user)){
|
||||
throw new IllegalArgumentException("User all ready member of paid group.");
|
||||
}else{
|
||||
if(!freeGroup.contains(user)){
|
||||
freeGroup.add(user);
|
||||
}
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param user {@link User} to be added to the free group
|
||||
*/
|
||||
public static void addUserToFreeGroup(final User user) {
|
||||
if (paidGroup.contains(user)) {
|
||||
throw new IllegalArgumentException("User all ready member of paid group.");
|
||||
} else {
|
||||
if (!freeGroup.contains(user)) {
|
||||
freeGroup.add(user);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void addUserToPaidGroup(final User user){
|
||||
if(freeGroup.contains(user)){
|
||||
throw new IllegalArgumentException("User all ready member of free group.");
|
||||
}else{
|
||||
if(!paidGroup.contains(user)){
|
||||
paidGroup.add(user);
|
||||
}
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param user {@link User} to be added to the paid group
|
||||
*/
|
||||
public static void addUserToPaidGroup(final User user) {
|
||||
if (freeGroup.contains(user)) {
|
||||
throw new IllegalArgumentException("User all ready member of free group.");
|
||||
} else {
|
||||
if (!paidGroup.contains(user)) {
|
||||
paidGroup.add(user);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isPaid(User user) {
|
||||
return paidGroup.contains(user);
|
||||
}
|
||||
public static boolean isPaid(User user) {
|
||||
return paidGroup.contains(user);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user