From db0caea58884a3c573d08a1e4290e73743c3b4b5 Mon Sep 17 00:00:00 2001 From: Denis Date: Thu, 30 Aug 2018 22:08:34 +0200 Subject: [PATCH] BAEL-2144 remove duplicated anagram validator from old location --- .../string/anagram/AnagramValidator.java | 29 ------------------- 1 file changed, 29 deletions(-) delete mode 100644 core-java/src/main/java/com/baeldung/sorting/string/anagram/AnagramValidator.java diff --git a/core-java/src/main/java/com/baeldung/sorting/string/anagram/AnagramValidator.java b/core-java/src/main/java/com/baeldung/sorting/string/anagram/AnagramValidator.java deleted file mode 100644 index a12571b2e2..0000000000 --- a/core-java/src/main/java/com/baeldung/sorting/string/anagram/AnagramValidator.java +++ /dev/null @@ -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+", ""); - } -} \ No newline at end of file