FieldAccessor implements Serializable { @SuppressWarnings("unchecked") public static <R, F> FieldAccessor<R, F> create(int pos, TypeInformation<R> typeInfo, ExecutionConfig config) { if (typeInfo.isTupleType() && ((TupleTypeInfoBase)typeInfo).isCaseClass()) { return new ProductFieldAccessor<R, F>(pos, typeInfo, config); } else if (typeInfo.isTupleType()) { return new TupleFieldAccessor<R, F>(pos, typeInfo); } else if (typeInfo instanceof BasicArrayTypeInfo || typeInfo instanceof PrimitiveArrayTypeInfo) { return new ArrayFieldAccessor<R, F>(pos, typeInfo); } else { if(pos != 0) { throw new IndexOutOfBoundsException("Not 0th field selected for a simple type (non-tuple, non-array)."); } return (FieldAccessor<R, F>) new SimpleFieldAccessor<R>(typeInfo); } }  @SuppressWarnings("unchecked") TypeInformation<F> getFieldType(); abstract F get(R record); abstract R set(R record, F fieldValue); @SuppressWarnings("unchecked") static FieldAccessor<R, F> create(int pos, TypeInformation<R> typeInfo, ExecutionConfig config); static FieldAccessor<R, F> create(String field, TypeInformation<R> typeInfo, ExecutionConfig config);  }
@Test @SuppressWarnings("unchecked") public void tupleFieldAccessorOutOfBoundsTest() { try { FieldAccessor<Tuple2<Integer, Integer>, Integer> fieldAccessor = (FieldAccessor<Tuple2<Integer, Integer>, Integer>) (Object) FieldAccessor.create(2, TupleTypeInfo.getBasicTupleTypeInfo(Integer.class, Integer.class), null); fail(); } catch (IndexOutOfBoundsException e) { } }