Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Override
- public Skill update(Skill skill) {
- List<Skill> currentSkills = this.service.getItemsFromFile(Skill.class);
- AtomicBoolean wasUpdated = new AtomicBoolean(false);
- currentSkills = currentSkills.stream()
- .map(s -> {
- if (Objects.equals(s.getId(), skill.getId())) {
- wasUpdated.set(true);
- return skill;
- }
- return s;
- })
- .collect(Collectors.toList());
- this.service.addItemsToFile(currentSkills);
- return wasUpdated.get() ? skill : null;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement