protected void checkType ( Object object ) { if ( object == null ) { throw new NullPointerException ( "Sequences cannot contain null, use a List instead" ) ; } if ( type != null ) { if ( ! type . isInstance ( object ) ) { throw new IllegalArgumentException ( "Invalid type of argument for sequence of type: " + type . getName ( ) + " cannot add object: " + object ) ; } } }
Checks that the given object instance is of the correct type otherwise a runtime exception is thrown