public static Integer size(Object value) {
        if (value != null) {
            if (value instanceof Collection<?> collection) {
                return collection.size();
            } else if (value instanceof Map<?, ?> map) {
                return map.size();
            } else if (value instanceof Object[] array) {
                return array.length;
            } else if (value.getClass().isArray()) {
                return Array.getLength(value);
            } else if (value instanceof NodeList nodeList) {
                return nodeList.getLength();
            }
        }
        return null;
    }
@Test
    public void testSize() {
        Map<String, Object> map = new HashMap<>();
        map.put("foo", 123);
        map.put("bar", 456);

        assertEquals(2, CollectionHelper.size(map).intValue());

        String[] array = new String[] { "Claus", "Willem" };
        assertEquals(2, CollectionHelper.size(array).intValue());
    }