Merge pull request '测试代码整合和 Default 关键字' (#69) from active_mq into main
Reviewed-on: https://src.ossez.com/iSharkfly-Docs/java-tutorials/pulls/69
This commit is contained in:
commit
5ba136fdc6
|
@ -1,32 +1,50 @@
|
|||
package com.ossez.toolkits.codebank;
|
||||
|
||||
import java.util.Properties;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
|
||||
import com.google.gdata.data.docs.Size;
|
||||
import org.apache.commons.cli.CommandLine;
|
||||
import org.apache.commons.cli.CommandLineParser;
|
||||
import org.apache.commons.cli.GnuParser;
|
||||
import org.apache.commons.cli.Options;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
* Main Test Class
|
||||
*
|
||||
* @author YuCheng Hu
|
||||
*/
|
||||
public class Main {
|
||||
|
||||
interface TestInterface1 {
|
||||
// default method
|
||||
default void show() {
|
||||
System.out.println("Default TestInterface - 1 ");
|
||||
}
|
||||
}
|
||||
|
||||
interface TestInterface2 {
|
||||
// Default method
|
||||
default void show() {
|
||||
System.out.println("Default TestInterface - 2");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class Main implements TestInterface1, TestInterface2 {
|
||||
private static final Logger logger = LoggerFactory.getLogger(Main.class);
|
||||
|
||||
private static Options options = new Options();
|
||||
private static Properties properties = new Properties();
|
||||
|
||||
private static CommandLine cl = null;
|
||||
|
||||
private static boolean dryRun = false;
|
||||
private static int limit = 0;
|
||||
private static boolean force = false;
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
new Main().show();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void show() {
|
||||
TestInterface1.super.show();
|
||||
TestInterface2.super.show();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import lombok.extern.slf4j.Slf4j;
|
|||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang3.RegExUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.math.NumberUtils;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
@ -37,80 +38,17 @@ public class EmptyQuickTest {
|
|||
|
||||
@Test
|
||||
public void testMain() {
|
||||
Integer[] nums = {2, 7, 11, 15};
|
||||
List<String> testList = new ArrayList<>();
|
||||
|
||||
Integer target = 9;
|
||||
|
||||
String s1 = "Question, what kind of bear is best?";
|
||||
String s2 = "That's a ridiculous question!";
|
||||
String s3 = "False.";
|
||||
String s4 = "Black bear is the best bear.";
|
||||
testList.add(String.valueOf(1L));
|
||||
testList.add("iSharkFly");
|
||||
testList.add(String.valueOf(2));
|
||||
testList.forEach(e -> log.debug("{}", e));
|
||||
|
||||
List<String> inputStr = new ArrayList<>();
|
||||
inputStr.add(RegExUtils.replaceAll(s1, "[^a-zA-Z\\s]", "").toLowerCase());
|
||||
inputStr.add(RegExUtils.replaceAll(s2, "[^a-zA-Z\\s]", "").toLowerCase());
|
||||
inputStr.add(RegExUtils.replaceAll(s3, "[^a-zA-Z\\s]", "").toLowerCase());
|
||||
inputStr.add(RegExUtils.replaceAll(s4, "[^a-zA-Z\\s]", "").toLowerCase());
|
||||
|
||||
HashMap<String, List<String>> wordsMap = new HashMap<>();
|
||||
|
||||
for (int i = 0; i < inputStr.size(); i++) {
|
||||
String words = inputStr.get(i);
|
||||
List<String> wordsList = List.of(StringUtils.split(inputStr.get(i)));
|
||||
for (int j = 0; j < wordsList.size(); j++) {
|
||||
String word = wordsList.get(j);
|
||||
List<String> inStr = new ArrayList<>();
|
||||
if (wordsMap.get(word) != null) {
|
||||
inStr = wordsMap.get(word);
|
||||
}
|
||||
inStr.add("" + (i + 1));
|
||||
wordsMap.put(word, inStr);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
TreeMap<Integer, List<String>> countMap = new TreeMap<>(Collections.reverseOrder());
|
||||
for (Map.Entry<String, List<String>> stringListEntry : wordsMap.entrySet()) {
|
||||
Integer wordCount = stringListEntry.getValue().size();
|
||||
List<String> wordsList = new ArrayList<>();
|
||||
if (countMap.get(wordCount) != null) {
|
||||
wordsList = countMap.get(wordCount);
|
||||
|
||||
}
|
||||
wordsList.add(stringListEntry.getKey());
|
||||
countMap.put(wordCount, wordsList);
|
||||
}
|
||||
|
||||
for (Map.Entry<Integer, List<String>> integerListEntry : countMap.entrySet()) {
|
||||
List<String> outputList = integerListEntry.getValue();
|
||||
for (int i = 0; i < outputList.size(); i++) {
|
||||
List<String> sList = wordsMap.get(outputList.get(i));
|
||||
log.debug("{}[{}:{}]", outputList.get(i), integerListEntry.getKey(), sList.stream().distinct().collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private Boolean hasVowels(String str) {
|
||||
|
||||
str = StringUtils.trimToEmpty(str);
|
||||
str = StringUtils.lowerCase(str);
|
||||
str = StringUtils.remove(str, " ");
|
||||
|
||||
if (StringUtils.contains(str, VOWEL_A)) {
|
||||
return Boolean.TRUE;
|
||||
} else if (StringUtils.contains(str, VOWEL_E)) {
|
||||
return Boolean.TRUE;
|
||||
} else if (StringUtils.contains(str, VOWEL_I)) {
|
||||
return Boolean.TRUE;
|
||||
} else if (StringUtils.contains(str, VOWEL_O)) {
|
||||
return Boolean.TRUE;
|
||||
} else if (StringUtils.contains(str, VOWEL_U)) {
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
|
||||
return Boolean.FALSE;
|
||||
String index0 = (String) testList.get(0);
|
||||
String index1 = (String) testList.get(1);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue