Checks if specified object is instance of specified class. Used for a dynamically typesafe view of the collections. @param obj - object is to be checked @param type - class of object that should be @return specified object
(E obj, Class<? extends E> type)
| 2679 | * @return specified object |
| 2680 | */ |
| 2681 | static <E> E checkType(E obj, Class<? extends E> type) { |
| 2682 | if (obj != null && !type.isInstance(obj)) { |
| 2683 | // luni.05=Attempt to insert {0} element into collection with |
| 2684 | // element type {1} |
| 2685 | throw new ClassCastException(Messages.getString( |
| 2686 | "luni.05", obj.getClass(), type)); //$NON-NLS-1$ |
| 2687 | } |
| 2688 | return obj; |
| 2689 | } |
| 2690 | |
| 2691 | /** |
| 2692 | * Class represents a dynamically typesafe view of the specified collection. |