public static long getSize(Object object) {

        if (object == null) {
            return 0;
        } else if (object instanceof SizeObject) {
            return ((SizeObject) object).getSize();
        } else if (object instanceof Boolean) {
            return 1;
        } else if (object instanceof String) {
            return object.toString().length() * 256;
        } else if (object instanceof Number) {
            return object.toString().length();
        } else if (object instanceof Iterable) {
            long size = 0;
            for (Object entry : (Iterable<?>) object) {
                size += getSize(entry);
            }
            return size;
        } else {
            throw new IllegalArgumentException("Type " + object.getClass().getName() + " isn't a SizeObject, string, boolean or number");
        }
    }