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

cleanup

parent f3352b0e
......@@ -92,17 +92,12 @@ public class TasksRepository implements Repository
//todo: refactor with the function below
private Optional<Pair<Task, Flag>> getTaskFlagPairByHashValue(User user, String userHash, int taskLevel)
{
//todo: find TASK by level
//todo: inline
String username = user.getName();
Task task = getByLevel(taskLevel);
List<Flag> flags = task.getFlags();
Optional<Flag> matchedFlag = flags.stream()
Optional<Flag> matchedFlag = getByLevel(taskLevel).getFlags().stream()
.filter(flag -> calculateHashValue(username, flag.getValue()).equals(userHash))
.findFirst();
//todo: use orElse
if(matchedFlag.isPresent()) {
return Optional.of(new Pair<>(task, matchedFlag.get()));
if (matchedFlag.isPresent()) {
return Optional.of(new Pair<>(getByLevel(taskLevel), matchedFlag.get()));
}
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