@SuppressWarnings("unchecked") // cast to generic Map will always be okay in this case
    private void validateEventValue(Object value, int depth) {
        if (value instanceof String) {
            String strValue = (String) value;
            if (strValue.length() >= 10000) {
                throw new InvalidEventException("An event cannot contain a string property value longer than 10," +
                        "000 characters.");
            }
        } else if (value instanceof Map) {
            validateEvent((Map<String, Object>) value, depth + 1);
        } else if (value instanceof Iterable) {
            for (Object listElement : (Iterable) value) {
                validateEventValue(listElement, depth);
            }
        }
    }
@ SuppressWarnings ( "unchecked" ) private void validateEventValue ( Object value , int depth ) { if ( value instanceof String ) { String strValue = ( String ) value ; if ( strValue . length ( ) >= 10000 ) { throw new InvalidEventException ( "An event cannot contain a string property value longer than 10," + "000 characters." ) ; } } else if ( value instanceof Map ) { validateEvent ( ( Map < String , Object > ) value , depth + 1 ) ; } else if ( value instanceof Iterable ) { for ( Object listElement : ( Iterable ) value ) { validateEventValue ( listElement , depth ) ; } } }
Validates a value within an event structure. This method will handle validating each element
in a list, as well as recursively validating nested maps.

@param value The value to validate.
@param depth The current depth of validation.