Serializer started x4
This commit is contained in:
parent
1d728936fb
commit
cbed861375
2
pom.xml
2
pom.xml
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
<groupId>com.alterdekim.game</groupId>
|
<groupId>com.alterdekim.game</groupId>
|
||||||
<artifactId>actionScriptDecompiler</artifactId>
|
<artifactId>actionScriptDecompiler</artifactId>
|
||||||
<version>0.0.9</version>
|
<version>0.0.10</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>SWFDissect</name>
|
<name>SWFDissect</name>
|
||||||
|
@ -13,6 +13,31 @@ import java.util.stream.Collectors;
|
|||||||
@Slf4j
|
@Slf4j
|
||||||
public class FlashMapper {
|
public class FlashMapper {
|
||||||
|
|
||||||
|
public static <T> Map<String, Object> simpleToMap(List<T> l) {
|
||||||
|
Map<String, Object> m = new HashMap<>();
|
||||||
|
for( T o : l ) {
|
||||||
|
List<Field> 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 <T> Map<String, Object> objToMap(List<T> l) {
|
public static <T> Map<String, Object> objToMap(List<T> l) {
|
||||||
Map<String, Object> m = new HashMap<>();
|
Map<String, Object> m = new HashMap<>();
|
||||||
for( T o : l ) {
|
for( T o : l ) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user