sclass SizeEstimate { new Map shallowFieldSizes; new Set complexFields; new Map complexFieldSizes; } static SizeEstimate estimateWebBotSize(O o) { new SizeEstimate se; Collection fields = fields(o); for (S field : fields) { O value = get(o, field); if (value == null) continue; Class type = value.getClass(); if (isBoxedType(type) || isPrimitiveArray(value)) continue with shallowFieldSizes.put(field, deepObjectSize(value)); se.complexFields.add(field); }); ret se; }