package org.kepennar.aproc.complicatebusiness;

import static java.util.stream.Collectors.toList;

import java.util.List;

import javax.inject.Inject;

import org.kepennar.aproc.tasks.Task;
import org.kepennar.aproc.tasks.TaskRepository;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

@Service
public class ComplicateBusinessService {

	private final TaskRepository taskRepository;
	
	@Inject
	public ComplicateBusinessService(TaskRepository taskRepository) {
		this.taskRepository = taskRepository;
	}
	
	public List<Task> getAllTransformedTasks() {
		return taskRepository.findAll().parallelStream()
			.map(t -> {
				return new Task(sort(t.getName()), sort(t.getDescription()));
			})
			.collect(toList());
		
	}
	
	private final static String sort(String word) {
		return String.join("", 
				StringUtils.sortStringArray(word.split(""))
				);
	}
	
}

@@ -41,16 +41,116 @@
 iness;%0A%0A
+import static java.util.Comparator.naturalOrder;%0Aimport static java.util.stream.Collectors.joining;%0A
 import s
@@ -210,24 +210,56 @@
 a.util.List;
+%0Aimport java.util.stream.Stream;
 %0A%0Aimport jav
@@ -413,53 +413,8 @@
 ice;
-%0Aimport org.springframework.util.StringUtils;
 %0A%0A@S
@@ -763,24 +763,25 @@
 ew Task(sort
+2
 (t.getName()
@@ -787,16 +787,17 @@
 )), sort
+2
 (t.getDe
@@ -846,18 +846,16 @@
 ;%0A%09%09%0A%09%7D%0A
-%09%0A
 %09private
@@ -879,16 +879,17 @@
 ing sort
+2
 (String 
@@ -912,76 +912,86 @@
  Str
-ing.join(%22%22, 
+eam.of(word.split(%22%22))
 %0A%09%09%09%09
-StringUtils.sortStringArray(word.split(%22%22))%0A%09%09%09%09);
+.sorted(naturalOrder())%0A%09%09%09%09.collect(joining());%0A%09%09
 %0A%09%7D%0A

Use Stream instead of StringUtils