Checks that the given object instance is of the correct type otherwise a runtime exception is thrown
(Object object)
| 287 | * otherwise a runtime exception is thrown |
| 288 | */ |
| 289 | protected void checkType(Object object) { |
| 290 | if (object == null) { |
| 291 | throw new NullPointerException("Sequences cannot contain null, use a List instead"); |
| 292 | } |
| 293 | if (type != null) { |
| 294 | if (!type.isInstance(object)) { |
| 295 | throw new IllegalArgumentException( |
| 296 | "Invalid type of argument for sequence of type: " |
| 297 | + type.getName() |
| 298 | + " cannot add object: " |
| 299 | + object); |
| 300 | } |
| 301 | } |
| 302 | } |
| 303 | } |
no test coverage detected