1
mirror of https://github.com/CarmJos/EasyConfiguration.git synced 2026-06-04 10:38:19 +08:00
huanmeng-qwq
2025-09-27 02:59:34 +08:00
committed by Carm
parent 4a0e6b0676
commit 6a03d446a3
@@ -88,8 +88,9 @@ public class ValueAdapterRegistry {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public <T> @Nullable ValueAdapter<T> adapterOf(@NotNull ValueType<T> type) { public <T> @Nullable ValueAdapter<T> adapterOf(@NotNull ValueType<T> type) {
ValueAdapter<?> cached = adapterCache.get(type); if (adapterCache.containsKey(type)) {
if (cached != null) return (ValueAdapter<T>) cached; return (ValueAdapter<T>) adapterCache.get(type);
}
for (ValueAdapter<?> adapter : adapters) { for (ValueAdapter<?> adapter : adapters) {
if (adapter.type().equals(type)) { if (adapter.type().equals(type)) {
@@ -154,11 +155,14 @@ public class ValueAdapterRegistry {
private <T> T deserializeArray(@NotNull ConfigurationHolder<?> holder, @NotNull ValueType<T> type, private <T> T deserializeArray(@NotNull ConfigurationHolder<?> holder, @NotNull ValueType<T> type,
@NotNull Object source, @NotNull Class<?> rawType) throws Exception { @NotNull Object source, @NotNull Class<?> rawType) throws Exception {
if (!(source instanceof List<?>)) { List<?> list;
source = deserializeList(holder, type, source); if (source instanceof List<?>) {
list = (List<?>) source;
} else {
// For non-list sources, treat as single element array
list = Collections.singletonList(source);
} }
List<?> list = (List<?>) source;
int size = list.size(); int size = list.size();
if (size == 0) { if (size == 0) {
return type.cast(Array.newInstance(rawType.getComponentType(), 0)); return type.cast(Array.newInstance(rawType.getComponentType(), 0));