mirror of
https://github.com/dalbodeule/snap-admin.git
synced 2025-06-08 21:38:21 +00:00
Using more generic Collection instead of List (avoid ClassCastException for Sets or similar)
This commit is contained in:
parent
c1ec3425b5
commit
c81b495222
@ -22,6 +22,7 @@ package tech.ailef.snapadmin.external.dbmapping;
|
|||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -108,7 +109,7 @@ public class DbObject {
|
|||||||
ManyToMany manyToMany = field.getPrimitiveField().getAnnotation(ManyToMany.class);
|
ManyToMany manyToMany = field.getPrimitiveField().getAnnotation(ManyToMany.class);
|
||||||
OneToMany oneToMany = field.getPrimitiveField().getAnnotation(OneToMany.class);
|
OneToMany oneToMany = field.getPrimitiveField().getAnnotation(OneToMany.class);
|
||||||
if (manyToMany != null || oneToMany != null) {
|
if (manyToMany != null || oneToMany != null) {
|
||||||
List<Object> linkedObjects = (List<Object>)get(field.getJavaName()).getValue();
|
Collection<Object> linkedObjects = (Collection<Object>)get(field.getJavaName()).getValue();
|
||||||
return linkedObjects.stream().map(o -> new DbObject(o, field.getConnectedSchema()))
|
return linkedObjects.stream().map(o -> new DbObject(o, field.getConnectedSchema()))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user