-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixing registration and account form validation
- Loading branch information
Showing
5 changed files
with
65 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
src/main/java/hu/isakots/martosgym/service/util/ApplicationUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package hu.isakots.martosgym.service.util; | ||
|
||
import hu.isakots.martosgym.domain.Subscription; | ||
import hu.isakots.martosgym.domain.User; | ||
import hu.isakots.martosgym.service.model.SubscriptionType; | ||
|
||
import java.util.Set; | ||
import java.util.stream.Collectors; | ||
|
||
/** | ||
* Utility class for application logic | ||
*/ | ||
public final class ApplicationUtil { | ||
|
||
private ApplicationUtil() { | ||
// utility class | ||
} | ||
|
||
public static void mapSubscriptions(Set<String> subscriptionList, User storedUser) { | ||
storedUser.setSubscriptions( | ||
subscriptionList.stream() | ||
.map(subscriptionName -> { | ||
Subscription subscription = new Subscription(); | ||
try { | ||
subscription.setName(SubscriptionType.valueOf(subscriptionName)); | ||
} catch (IllegalArgumentException | NullPointerException exception) { | ||
throw new UnsupportedOperationException("Invalid subscriptionType"); | ||
} | ||
return subscription; | ||
}) | ||
.collect(Collectors.toSet()) | ||
); | ||
} | ||
} |