From c94f3d83e7fe88cd6844181ff1c37dcfcd488d10 Mon Sep 17 00:00:00 2001 From: LamGC Date: Fri, 23 Oct 2020 20:05:01 +0800 Subject: [PATCH] =?UTF-8?q?[Optimize]=20Common=20=E6=95=B4=E7=90=86?= =?UTF-8?q?=E4=BB=A3=E7=A0=81;?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [Optimize] CacheStoreBuilder 整理代码格式; --- .../cgj/bot/cache/CacheStoreBuilder.java | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/ContentGrabbingJi-common/src/main/java/net/lamgc/cgj/bot/cache/CacheStoreBuilder.java b/ContentGrabbingJi-common/src/main/java/net/lamgc/cgj/bot/cache/CacheStoreBuilder.java index a19aa9f..b081995 100644 --- a/ContentGrabbingJi-common/src/main/java/net/lamgc/cgj/bot/cache/CacheStoreBuilder.java +++ b/ContentGrabbingJi-common/src/main/java/net/lamgc/cgj/bot/cache/CacheStoreBuilder.java @@ -97,7 +97,8 @@ public class CacheStoreBuilder { * 获取一个当前可用的高优先级 Factory 对象. * @return 返回可用的高优先级 Factory 对象. */ - private static > R getFactory(CacheStoreSource storeSource, Function function) + private static > R getFactory(CacheStoreSource storeSource, + Function function) throws NoSuchFactoryException { if (FACTORY_LIST.size() == 0) { loadFactory(); @@ -130,8 +131,9 @@ public class CacheStoreBuilder { return result; } catch (Exception e) { if (!iterator.hasNext()) { - throw new NoSuchFactoryException(new GetCacheStoreException("CacheStoreFactory " + info.getFactoryName() + - " (" + factory.getClass().getName() + ") 创建 CacheStore 时发生异常.", e)); + throw new NoSuchFactoryException(new GetCacheStoreException("CacheStoreFactory " + + info.getFactoryName() + " (" + factory.getClass().getName() + + ") 创建 CacheStore 时发生异常.", e)); } else { if (e instanceof GetCacheStoreException) { log.warn("CacheStoreFactory '{} ({})' 无法提供相应 CacheStore. 原因: {}", @@ -167,7 +169,8 @@ public class CacheStoreBuilder { * @return 返回新的存储容器, 与其他容器互不干扰. * @throws GetCacheStoreException 当无法获取可用的 CacheStore 时抛出. */ - public static SingleCacheStore newSingleCacheStore(CacheStoreSource storeSource, String identify, StringConverter converter) { + public static SingleCacheStore newSingleCacheStore(CacheStoreSource storeSource, String identify, + StringConverter converter) { try { return getFactory(storeSource, factory -> { SingleCacheStore singleCacheStoreInstance = factory.newSingleCacheStore(identify, converter); @@ -202,7 +205,8 @@ public class CacheStoreBuilder { * @return 返回新的存储容器, 与其他容器互不干扰. * @throws GetCacheStoreException 当无法获取可用的 CacheStore 时抛出. */ - public static ListCacheStore newListCacheStore(CacheStoreSource storeSource, String identify, StringConverter converter) { + public static ListCacheStore newListCacheStore(CacheStoreSource storeSource, String identify, + StringConverter converter) { try { return getFactory(storeSource, factory -> { ListCacheStore listCacheStoreInstance = factory.newListCacheStore(identify, converter); @@ -236,7 +240,8 @@ public class CacheStoreBuilder { * @return 返回新的存储容器, 与其他容器互不干扰. * @throws GetCacheStoreException 当无法获取可用的 CacheStore 时抛出. */ - public static SetCacheStore newSetCacheStore(CacheStoreSource storeSource, String identify, StringConverter converter) { + public static SetCacheStore newSetCacheStore(CacheStoreSource storeSource, String identify, + StringConverter converter) { try { return getFactory(storeSource, factory -> { SetCacheStore setCacheStoreInstance = factory.newSetCacheStore(identify, converter); @@ -271,7 +276,8 @@ public class CacheStoreBuilder { * @return 返回新的存储容器, 与其他容器互不干扰. * @throws GetCacheStoreException 当无法获取可用的 CacheStore 时抛出. */ - public static MapCacheStore newMapCacheStore(CacheStoreSource storeSource, String identify, StringConverter converter) { + public static MapCacheStore newMapCacheStore(CacheStoreSource storeSource, String identify, + StringConverter converter) { try { return getFactory(storeSource, factory -> { MapCacheStore mapCacheStoreInstance = factory.newMapCacheStore(identify, converter);