Skip to content

Commit 421fa72

Browse files
ArrayingArraying
authored andcommitted
Version 0.4.5
1 parent 7454547 commit 421fa72

File tree

3 files changed

+13
-10
lines changed

3 files changed

+13
-10
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
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>

src/main/java/de/arraying/kotys/JSONArray.java

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import java.io.StringReader;
44
import java.lang.reflect.Array;
55
import 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);

src/main/java/de/arraying/kotys/JSONORM.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff 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");

0 commit comments

Comments
 (0)