class 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);
		}
	}

}