(final ELContext ctx, final Object obj, final Class<?> type)
| 639 | } |
| 640 | |
| 641 | private static Object coerceToArray(final ELContext ctx, final Object obj, final Class<?> type) { |
| 642 | // Note: Nested arrays will result in nested calls to this method. |
| 643 | |
| 644 | // Note: Calling method has checked the obj is an array. |
| 645 | |
| 646 | int size = Array.getLength(obj); |
| 647 | // Cast the input object to an array (calling method has checked it is |
| 648 | // an array) |
| 649 | // Get the target type for the array elements |
| 650 | Class<?> componentType = type.getComponentType(); |
| 651 | // Create a new array of the correct type |
| 652 | Object result = Array.newInstance(componentType, size); |
| 653 | // Coerce each element in turn. |
| 654 | for (int i = 0; i < size; i++) { |
| 655 | Array.set(result, i, coerceToType(ctx, Array.get(obj, i), componentType)); |
| 656 | } |
| 657 | |
| 658 | return result; |
| 659 | } |
| 660 | |
| 661 | |
| 662 | private static <T> T coerceToFunctionalInterface(final ELContext ctx, final LambdaExpression lambdaExpression, |
no test coverage detected