@Override
    public Object evaluateUnsafe(EvaluationContext context) {
        final Object idxObj = this.index.evaluateUnsafe(context);
        final Object indexable = indexableObject.evaluateUnsafe(context);
        if (idxObj == null || indexable == null) {
            return null;
        }

        if (idxObj instanceof Long) {
            int idx = Ints.saturatedCast((long) idxObj);
            if (indexable.getClass().isArray()) {
                return Array.get(indexable, idx);
            } else if (indexable instanceof List) {
                return ((List) indexable).get(idx);
            } else if (indexable instanceof Iterable) {
                return Iterables.get((Iterable) indexable, idx);
            }
            throw new IllegalArgumentException(
                    context.pipelineErrorMessage("Object '" + indexable + "' is not an Array, List or Iterable."));
        } else if (idxObj instanceof String) {
            final String idx = idxObj.toString();
            if (indexable instanceof Map) {
                return ((Map) indexable).get(idx);
            }
            throw new IllegalArgumentException(
                    context.pipelineErrorMessage("Object '" + indexable + "' is not a Map."));
        }
        throw new IllegalArgumentException(
                context.pipelineErrorMessage("Index '" + idxObj + "' is not a Long or String."));
    }
@Test
    public void invalidObject() {
        final IndexedAccessExpression expression = new IndexedAccessExpression(START, obj(23), num(0));

        // this should throw an exception
        assertThatExceptionOfType(IllegalArgumentException.class)
                .isThrownBy(() -> expression.evaluateUnsafe(context));
    }