(@NotNull IntFunction<Log> s)
| 34 | private static final LongConcurrentHashMap<IntFunction<Log>> factorys = new LongConcurrentHashMap<>(); |
| 35 | |
| 36 | public static void register(@NotNull IntFunction<Log> s) { |
| 37 | var ins = s.apply(0); |
| 38 | var old = factorys.putIfAbsent(ins.getTypeId(), s); |
| 39 | if (old == null) |
| 40 | logger.debug("register log typeId({}): {}", ins.getTypeId(), ins.getTypeName()); |
| 41 | else { |
| 42 | var oldIns = old.apply(0); |
| 43 | if (!oldIns.getTypeName().equals(ins.getTypeName())) { |
| 44 | logger.error("register duplicated log typeId({}): {} & {}", |
| 45 | ins.getTypeId(), oldIns.getTypeName(), ins.getTypeName()); |
| 46 | } |
| 47 | } |
| 48 | } |
| 49 | |
| 50 | public static @NotNull Log create(int typeId, int varId) { |
| 51 | var factory = factorys.get(typeId); |
no test coverage detected