File tree Expand file tree Collapse file tree 3 files changed +13
-10
lines changed
src/main/java/de/arraying/kotys Expand file tree Collapse file tree 3 files changed +13
-10
lines changed Original file line number Diff line number Diff line change 55 <modelVersion >4.0.0</modelVersion >
66 <groupId >de.arraying</groupId >
77 <artifactId >Kotys</artifactId >
8- <version >0.4.4 </version >
8+ <version >0.4.5 </version >
99 <build >
1010 <plugins >
1111 <plugin >
Original file line number Diff line number Diff line change 33import java .io .StringReader ;
44import java .lang .reflect .Array ;
55import java .util .*;
6- import java .util .stream .Collectors ;
76
87/**
98 * Copyright 2017 Arraying
@@ -258,10 +257,18 @@ public final String marshal() {
258257 */
259258 @ SuppressWarnings ("unchecked" )
260259 public final <T > T [] marshal (Class <T > clazz ) {
261- List <Object > objects = rawContent
262- .stream ()
263- .filter (entry -> entry .getClass ().equals (clazz ))
264- .collect (Collectors .toList ());
260+ List <Object > objects = new ArrayList <>();
261+ for (Object raw : rawContent ) {
262+ if (raw instanceof JSON ) {
263+ try {
264+ objects .add (((JSON ) raw ).marshal (clazz ));
265+ } catch (Exception ignored ) {}
266+ } else {
267+ if (raw .getClass ().equals (clazz )) {
268+ objects .add (raw );
269+ }
270+ }
271+ }
265272 Object [] array = (Object []) Array .newInstance (clazz , objects .size ());
266273 for (int i = 0 ; i < array .length ; i ++) {
267274 array [i ] = objects .get (i );
Original file line number Diff line number Diff line change @@ -135,10 +135,6 @@ T mapTo(JSON json, String... ignoredJSONKeys)
135135 if (rawValue instanceof JSON ) {
136136 value = ((JSON ) rawValue ).marshal (field .getType ());
137137 } else if (rawValue instanceof JSONArray ) {
138- JSONArray jsonArray = (JSONArray ) rawValue ;
139- if (jsonArray .length () == 0 ) {
140- continue ;
141- }
142138 Class <?> fieldType = field .getType ().getComponentType ();
143139 if (fieldType .isPrimitive ()) {
144140 throw new IllegalArgumentException ("Array type " + fieldType + " is primitive" );
You can’t perform that action at this time.
0 commit comments