public static int size(Object object) {
        int total = 0;
        if (object instanceof Map) {
            total = ((Map) object).size();
        } else if (object instanceof Collection) {
            total = ((Collection) object).size();
        } else if (object instanceof Object[]) {
            total = ((Object[]) object).length;
        } else if (object instanceof Iterator) {
            Iterator it = (Iterator) object;
            while (it.hasNext()) {
                total++;
                it.next();
            }
        } else if (object instanceof Enumeration) {
            Enumeration it = (Enumeration) object;
            while (it.hasMoreElements()) {
                total++;
                it.nextElement();
            }
        } else if (object == null) {
            throw new IllegalArgumentException("Unsupported object type: null");
        } else {
            try {
                total = Array.getLength(object);
            } catch (IllegalArgumentException ex) {
                throw new IllegalArgumentException("Unsupported object type: " + object.getClass().getName());
            }
        }
        return total;
    }
@Test
    void testSize() {
        // collection
        assertEquals(0, CollectionUtils.size(Collections.emptyList()));
        assertEquals(1, CollectionUtils.size(Collections.singletonList("")));
        assertEquals(10, CollectionUtils.size(IntStream.range(0, 10).boxed().collect(Collectors.toList())));
        
        // map
        Map<String, String> map = new HashMap<>();
        map.put("key1", "value1");
        assertEquals(1, CollectionUtils.size(map));
        map.put("key2", "value2");
        assertEquals(2, CollectionUtils.size(map));
        map.put("key3", "value3");
        assertEquals(3, CollectionUtils.size(map));
        
        // array
        assertEquals(1, CollectionUtils.size(new Object[] {"1"}));
        assertEquals(2, CollectionUtils.size(new Object[] {"1", "2"}));
        assertEquals(6, CollectionUtils.size(new Object[] {"1", "2", "3", "4", "5", "6"}));
        assertEquals(1000, CollectionUtils.size(IntStream.range(0, 1000).boxed().toArray()));
        
        // primitive array
        assertEquals(1, CollectionUtils.size(new int[] {1}));
        assertEquals(2, CollectionUtils.size(new int[] {1, 2}));
        assertEquals(6, CollectionUtils.size(new int[] {1, 2, 3, 4, 5, 6}));
        assertEquals(1000, CollectionUtils.size(IntStream.range(0, 1000).toArray()));
        
        // iterator
        assertEquals(1, CollectionUtils.size(Collections.singleton("1").iterator()));
        assertEquals(2, CollectionUtils.size(Arrays.asList("1", "2").iterator()));
        
        // enumeration
        assertEquals(0, CollectionUtils.size(asEnumeration(Collections.emptyIterator())));
        assertEquals(1, CollectionUtils.size(asEnumeration(Collections.singleton("").iterator())));
    }