Commit 022e49be authored by Grzegorz Pietrusza's avatar Grzegorz Pietrusza

cleanup

parent f3352b0e
...@@ -92,17 +92,12 @@ public class TasksRepository implements Repository ...@@ -92,17 +92,12 @@ public class TasksRepository implements Repository
//todo: refactor with the function below //todo: refactor with the function below
private Optional<Pair<Task, Flag>> getTaskFlagPairByHashValue(User user, String userHash, int taskLevel) private Optional<Pair<Task, Flag>> getTaskFlagPairByHashValue(User user, String userHash, int taskLevel)
{ {
//todo: find TASK by level
//todo: inline
String username = user.getName(); String username = user.getName();
Task task = getByLevel(taskLevel); Optional<Flag> matchedFlag = getByLevel(taskLevel).getFlags().stream()
List<Flag> flags = task.getFlags();
Optional<Flag> matchedFlag = flags.stream()
.filter(flag -> calculateHashValue(username, flag.getValue()).equals(userHash)) .filter(flag -> calculateHashValue(username, flag.getValue()).equals(userHash))
.findFirst(); .findFirst();
//todo: use orElse if (matchedFlag.isPresent()) {
if(matchedFlag.isPresent()) { return Optional.of(new Pair<>(getByLevel(taskLevel), matchedFlag.get()));
return Optional.of(new Pair<>(task, matchedFlag.get()));
} }
return Optional.empty(); return Optional.empty();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment