From 421fa72f625ad792fa2e73914bef3cad782e51de Mon Sep 17 00:00:00 2001 From: Arraying Date: Sun, 17 Jun 2018 13:22:02 +0200 Subject: [PATCH] Version 0.4.5 --- pom.xml | 2 +- src/main/java/de/arraying/kotys/JSONArray.java | 17 ++++++++++++----- src/main/java/de/arraying/kotys/JSONORM.java | 4 ---- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/pom.xml b/pom.xml index 41bc12d..88df252 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ 4.0.0 de.arraying Kotys - 0.4.4 + 0.4.5 diff --git a/src/main/java/de/arraying/kotys/JSONArray.java b/src/main/java/de/arraying/kotys/JSONArray.java index b6b944d..737f3fc 100644 --- a/src/main/java/de/arraying/kotys/JSONArray.java +++ b/src/main/java/de/arraying/kotys/JSONArray.java @@ -3,7 +3,6 @@ import java.io.StringReader; import java.lang.reflect.Array; import java.util.*; -import java.util.stream.Collectors; /** * Copyright 2017 Arraying @@ -258,10 +257,18 @@ public final String marshal() { */ @SuppressWarnings("unchecked") public final T[] marshal(Class clazz) { - List objects = rawContent - .stream() - .filter(entry -> entry.getClass().equals(clazz)) - .collect(Collectors.toList()); + List objects = new ArrayList<>(); + for(Object raw : rawContent) { + if(raw instanceof JSON) { + try { + objects.add(((JSON) raw).marshal(clazz)); + } catch(Exception ignored) {} + } else { + if(raw.getClass().equals(clazz)) { + objects.add(raw); + } + } + } Object[] array = (Object[]) Array.newInstance(clazz, objects.size()); for(int i = 0; i < array.length; i++) { array[i] = objects.get(i); diff --git a/src/main/java/de/arraying/kotys/JSONORM.java b/src/main/java/de/arraying/kotys/JSONORM.java index 442519f..4ad90a2 100644 --- a/src/main/java/de/arraying/kotys/JSONORM.java +++ b/src/main/java/de/arraying/kotys/JSONORM.java @@ -135,10 +135,6 @@ T mapTo(JSON json, String... ignoredJSONKeys) if(rawValue instanceof JSON) { value = ((JSON) rawValue).marshal(field.getType()); } else if(rawValue instanceof JSONArray) { - JSONArray jsonArray = (JSONArray) rawValue; - if(jsonArray.length() == 0) { - continue; - } Class fieldType = field.getType().getComponentType(); if(fieldType.isPrimitive()) { throw new IllegalArgumentException("Array type " + fieldType + " is primitive");