| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- package com.sckw.excel.translate;
- import com.sckw.core.exception.SourceInitializeException;
- import lombok.extern.slf4j.Slf4j;
- import java.util.HashMap;
- import java.util.Map;
- /**
- *
- * 数据源工具类
- *
- *
- * @author lfdc
- * @version v1
- * @create 2020-11-28 16:33:14
- * @copyright
- */
- @Slf4j
- //@Component
- //@Configuration
- public class SourceUtil {
- public static Map<com.sckw.excel.translate.enums.Source,
- com.sckw.excel.translate.context.Source> SOURCES_INSTANCE = new HashMap<>(2);
- public static void put(com.sckw.excel.translate.enums.Source source,
- com.sckw.excel.translate.context.Source instance) {
- SOURCES_INSTANCE.put(source, instance);
- }
- public static void remove(com.sckw.excel.translate.enums.Source source) {
- SOURCES_INSTANCE.remove(source);
- }
- public static void clear() {
- for (com.sckw.excel.translate.enums.Source source : SOURCES_INSTANCE.keySet()) {
- SOURCES_INSTANCE.get(source).clear();
- }
- }
- static Map<Integer, Object> get(com.sckw.excel.translate.enums.Source source) throws SourceInitializeException {
- try {
- return SOURCES_INSTANCE.get(source).get();
- } catch (Exception e) {
- log.error("failed to get data source, ex:{}", e.toString());
- throw e;
- }
- }
- }
|