From 741e91bb784f3dbbdb1609c1bea2402f8d0524bc Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Tue, 23 Apr 2019 06:23:03 +0200 Subject: [PATCH] JSonSerializerWithAccessFilter - idea for generalization of field types --- .../service/accessfilter/JSonSerializerWithAccessFilter.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/org/hostsharing/hsadminng/service/accessfilter/JSonSerializerWithAccessFilter.java b/src/main/java/org/hostsharing/hsadminng/service/accessfilter/JSonSerializerWithAccessFilter.java index 2e6ce295..2d30b251 100644 --- a/src/main/java/org/hostsharing/hsadminng/service/accessfilter/JSonSerializerWithAccessFilter.java +++ b/src/main/java/org/hostsharing/hsadminng/service/accessfilter/JSonSerializerWithAccessFilter.java @@ -33,6 +33,9 @@ public class JSonSerializerWithAccessFilter extends JsonSerializer { if (getLoginUserRole().isAllowedToRead(prop)) { final String fieldName = prop.getName(); // TODO: maybe replace by serializerProvider.defaultSerialize...()? + // But that's difficult for parallel structure with the deserializer, where the API is ugly. + // Alternatively extract the supported types to subclasses of some abstract class and + // here as well as in the deserializer just access the matching implementation through a map. if (Integer.class.isAssignableFrom(prop.getType()) || int.class.isAssignableFrom(prop.getType())) { jsonGenerator.writeNumberField(fieldName, (int) get(dto, prop)); } else if (Long.class.isAssignableFrom(prop.getType()) || long.class.isAssignableFrom(prop.getType())) {