From eeee6f43e4df01142aa96fa704df05ab0509f080 Mon Sep 17 00:00:00 2001 From: zengwei-cogiot Date: Tue, 12 Sep 2023 15:53:52 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8E=BB=E9=99=A4=E6=97=A0=E6=95=88=E6=96=87?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../GenericMethodWithGenericClass.java | 42 ------------------- 1 file changed, 42 deletions(-) delete mode 100644 mallchat-tools/mallchat-frequency-control/src/main/java/com/abin/frequencycontrol/service/frequencycontrol/GenericMethodWithGenericClass.java diff --git a/mallchat-tools/mallchat-frequency-control/src/main/java/com/abin/frequencycontrol/service/frequencycontrol/GenericMethodWithGenericClass.java b/mallchat-tools/mallchat-frequency-control/src/main/java/com/abin/frequencycontrol/service/frequencycontrol/GenericMethodWithGenericClass.java deleted file mode 100644 index ff8d43b..0000000 --- a/mallchat-tools/mallchat-frequency-control/src/main/java/com/abin/frequencycontrol/service/frequencycontrol/GenericMethodWithGenericClass.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.abin.frequencycontrol.service.frequencycontrol; - -import java.util.function.Supplier; - - public class GenericMethodWithGenericClass { - - public T get(E value, Supplier supplier) throws Throwable { - if (value == null) { - throw new Exception("Error"); - } - try { - return supplier.get(); - } finally { - // 不管成功还是失败,都增加次数 - System.out.println("execute"); - } - } - - // 泛型方法 - public void printArray(E[] array) { - for (E item : array) { - System.out.println(item); - } - } - - - public static void main(String[] args) { - GenericMethodWithGenericClass example = new GenericMethodWithGenericClass<>(); - - Integer[] intArray = {1, 2, 3, 4, 5}; - String[] stringArray = {"Hello", "World"}; - - example.printArray(intArray); - example.printArray(stringArray); - - try { - System.out.println(example.get("hello", Math::random)); - } catch (Throwable e) { - throw new RuntimeException(e); - } - } - }