diff --git a/pom.xml b/pom.xml index 66163df..08109ab 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.alterdekim.game actionScriptDecompiler - 0.0.9 + 0.0.10 jar SWFDissect diff --git a/src/main/java/com/alterdekim/flash/decompiler/mapper/FlashMapper.java b/src/main/java/com/alterdekim/flash/decompiler/mapper/FlashMapper.java index b44935e..98beb07 100644 --- a/src/main/java/com/alterdekim/flash/decompiler/mapper/FlashMapper.java +++ b/src/main/java/com/alterdekim/flash/decompiler/mapper/FlashMapper.java @@ -13,6 +13,31 @@ import java.util.stream.Collectors; @Slf4j public class FlashMapper { + public static Map simpleToMap(List l) { + Map m = new HashMap<>(); + for( T o : l ) { + List fields = Arrays.stream(o.getClass().getDeclaredFields()) + .filter(f -> f.isAnnotationPresent(FlashValue.class)) + .collect(Collectors.toList()); + try { + String key = null; + Object val = null; + for (Field f : fields) { + f.setAccessible(true); + switch (f.getAnnotation(FlashValue.class).type()) { + case Id -> key = ((Long) f.get(o)).toString(); + case Value -> val = f.get(o); + } + } + if( key == null || val == null ) continue; + m.put(key, val); + } catch (IllegalAccessException e) { + log.error("FlashMapper valueGet error: {}", e.getMessage()); + } + } + return m; + } + public static Map objToMap(List l) { Map m = new HashMap<>(); for( T o : l ) {