/** * default implementation maps field values on the host object by name * * @return Map representation */ default Map<String,?> toMap(){ try { final Object o = unwrap(); Map<String, Object> result = new HashMap<>(); for (Field f : ReflectionCache.getFields(o.getClass())) { result.put(f.getName(),f.get(o)); } return result; } catch (Exception e) { throw ExceptionSoftener .throwSoftenedException(e); } } }
/** * default implementation maps field values on the host object by name * * @return Map representation */ default Map<String,?> toMap(){ try { final Object o = unwrap(); return ReflectionCache.getFields(o.getClass()) .stream() .collect(Collectors.toMap((Field f)->f.getName(),(Field f) ->{ try { return f.get(o); } catch (Exception e) { ExceptionSoftener.singleton.factory.getInstance().throwSoftenedException(e); return null; } })); } catch (Exception e) { ExceptionSoftener.singleton.factory.getInstance() .throwSoftenedException(e); return null; } } }