BAEL-2144 remove duplicated anagram validator from old location

This commit is contained in:
Denis 2018-08-30 22:08:34 +02:00
parent 61de6251ec
commit db0caea588
1 changed files with 0 additions and 29 deletions

View File

@ -1,29 +0,0 @@
package com.baeldung.sorting.string.anagram;
import java.util.Arrays;
public class AnagramValidator {
public static boolean isValid(String text, String anagram) {
text = prepare(text);
anagram = prepare(anagram);
String sortedText = sort(text);
String sortedAnagram = sort(anagram);
return sortedText.equals(sortedAnagram);
}
private static String sort(String text) {
char[] chars = prepare(text).toCharArray();
Arrays.sort(chars);
return new String(chars);
}
private static String prepare(String text) {
return text.toLowerCase()
.trim()
.replaceAll("\\s+", "");
}
}