package innovimax.mixthem.join;

import innovimax.mixthem.exceptions.MixException;
import innovimax.mixthem.interfaces.IJoinLine;

import java.util.LinkedList;
import java.util.StringTokenizer;
import java.util.stream.Collectors;

/**
* <p>Joins two lines on a common field.</p>
* <p>This is the default implementation of IJoinLine.</p>
* @see IJoinLine
* @author Innovimax
* @version 1.0
*/
public class DefaultLineJoining implements IJoinLine {

	@Override
	public String join(String line1, String line2) throws MixException {
		LinkedList<String> list1 = new LinkedList<String>();
		StringTokenizer st1 = new StringTokenizer(line1, " ");
		while (st1.hasMoreTokens()) {
			list1.add(st1.nextToken());
		}
		LinkedList<String> list2 = new LinkedList<String>();
		StringTokenizer st2 = new StringTokenizer(line2, " ");
		while (st2.hasMoreTokens()) {
			list2.add(st2.nextToken());
		}
		if (list2.contains(list1.getFirst())) {
			String part1 = list1.stream().collect(Collectors.joining(" "));
			String part2 = list2.stream().filter(s -> !list1.contains(s)).collect(Collectors.joining(" "));
			return part1 + " " + part2;
		}
		return null;
	}

}

@@ -141,26 +141,22 @@
 va.util.
-LinkedList
+Arrays
 ;%0Aimport
@@ -166,31 +166,20 @@
 va.util.
-StringTokenizer
+List
 ;%0Aimport
@@ -513,193 +513,112 @@
 %7B%0A%09%09
-LinkedList%3CString%3E list
+if ((line
 1 
+!
 = n
-ew LinkedList%3CString%3E();%0A%09%09StringTokenizer st1 = new StringTokenizer(line1, %22 %22);%0A%09%09while (st1.hasMoreTokens()) %7B%0A%09%09%09list1.add(st1.nextToken(
+ull) && (line2 != null)) %7B%0A%09%09%09List%3CString%3E list1 = Arrays.asList(line1.split(%22%5C%5Cs%22
 ));%0A%09
-%09%7D%0A
 %09%09
-Linked
 List
@@ -638,158 +638,72 @@
 2 = 
-new LinkedList%3CString%3E();%0A%09%09StringTokenizer st2 = new StringTokenizer(line2, %22 %22);%0A%09%09while (st2.hasMoreTokens()) %7B%0A%09%09%09list2.add(st2.nextToken());%0A%09%09%7D%0A
+Arrays.asList(line2.split(%22%5C%5Cs%22));%0A%09%09%09if (list1.size() %3E 0) %7B%0A%09%09
 %09%09if
@@ -732,20 +732,18 @@
 .get
-First
 (
+0
 ))) %7B%0A
+%09%09
 %09%09%09S
@@ -808,16 +808,18 @@
 %22));%0A%09%09%09
+%09%09
 String p
@@ -909,16 +909,18 @@
 %22));%0A%09%09%09
+%09%09
 return p
@@ -939,16 +939,27 @@
  part2;%0A
+%09%09%09%09%7D%0A%09%09%09%7D%0A
 %09%09%7D%0A%09%09re

Update DefaultLineJoining.java