private void setOrderOfPOJOFields(String[] fieldNames) { Preconditions.checkNotNull(fieldNames); int includedCount = 0; for (boolean isIncluded : fieldIncluded) { if (isIncluded) { includedCount++; } } Preconditions.checkArgument(includedCount == fieldNames.length, includedCount + " CSV fields and " + fieldNames.length + " POJO fields selected. The number of selected CSV and POJO fields must be equal."); for (String field : fieldNames) { Preconditions.checkNotNull(field, "The field name cannot be null."); Preconditions.checkArgument(pojoTypeInfo.getFieldIndex(field) != -1, "Field \"" + field + "\" is not a member of POJO class " + pojoTypeClass.getName()); } pojoFieldNames = Arrays.copyOfRange(fieldNames, 0, fieldNames.length); }
private void configure(String lineDelimiter, String fieldDelimiter, PojoTypeInfo<OUT> pojoTypeInfo, String[] fieldNames, boolean[] includedFieldsMask) { if (includedFieldsMask == null) { includedFieldsMask = createDefaultMask(fieldNames.length); } for (String name : fieldNames) { if (name == null) { throw new NullPointerException("Field name must not be null."); } if (pojoTypeInfo.getFieldIndex(name) < 0) { throw new IllegalArgumentException("Field \"" + name + "\" not part of POJO type " + pojoTypeInfo.getTypeClass().getCanonicalName()); } } setDelimiter(lineDelimiter); setFieldDelimiter(fieldDelimiter); Class<?>[] classes = new Class<?>[fieldNames.length]; for (int i = 0; i < fieldNames.length; i++) { try { classes[i] = pojoTypeInfo.getTypeAt(pojoTypeInfo.getFieldIndex(fieldNames[i])).getTypeClass(); } catch (IndexOutOfBoundsException e) { throw new IllegalArgumentException("Invalid field name: " + fieldNames[i]); } } this.pojoTypeClass = pojoTypeInfo.getTypeClass(); this.pojoTypeInfo = pojoTypeInfo; setFieldsGeneric(includedFieldsMask, classes); setOrderOfPOJOFields(fieldNames); }
PojoTypeInfo<?> pojoTypeInfo = (PojoTypeInfo) typeInfo; int fieldIndex = pojoTypeInfo.getFieldIndex(decomp.head);
private void setOrderOfPOJOFields(String[] fieldNames) { Preconditions.checkNotNull(fieldNames); int includedCount = 0; for (boolean isIncluded : fieldIncluded) { if (isIncluded) { includedCount++; } } Preconditions.checkArgument(includedCount == fieldNames.length, includedCount + " CSV fields and " + fieldNames.length + " POJO fields selected. The number of selected CSV and POJO fields must be equal."); for (String field : fieldNames) { Preconditions.checkNotNull(field, "The field name cannot be null."); Preconditions.checkArgument(pojoTypeInfo.getFieldIndex(field) != -1, "Field \"" + field + "\" is not a member of POJO class " + pojoTypeClass.getName()); } pojoFieldNames = Arrays.copyOfRange(fieldNames, 0, fieldNames.length); }
private void setOrderOfPOJOFields(String[] fieldNames) { Preconditions.checkNotNull(fieldNames); int includedCount = 0; for (boolean isIncluded : fieldIncluded) { if (isIncluded) { includedCount++; } } Preconditions.checkArgument(includedCount == fieldNames.length, includedCount + " CSV fields and " + fieldNames.length + " POJO fields selected. The number of selected CSV and POJO fields must be equal."); for (String field : fieldNames) { Preconditions.checkNotNull(field, "The field name cannot be null."); Preconditions.checkArgument(pojoTypeInfo.getFieldIndex(field) != -1, "Field \"" + field + "\" is not a member of POJO class " + pojoTypeClass.getName()); } pojoFieldNames = Arrays.copyOfRange(fieldNames, 0, fieldNames.length); }
private void configure(String lineDelimiter, String fieldDelimiter, PojoTypeInfo<OUT> pojoTypeInfo, String[] fieldNames, boolean[] includedFieldsMask) { if (includedFieldsMask == null) { includedFieldsMask = createDefaultMask(fieldNames.length); } for (String name : fieldNames) { if (name == null) { throw new NullPointerException("Field name must not be null."); } if (pojoTypeInfo.getFieldIndex(name) < 0) { throw new IllegalArgumentException("Field \"" + name + "\" not part of POJO type " + pojoTypeInfo.getTypeClass().getCanonicalName()); } } setDelimiter(lineDelimiter); setFieldDelimiter(fieldDelimiter); Class<?>[] classes = new Class<?>[fieldNames.length]; for (int i = 0; i < fieldNames.length; i++) { try { classes[i] = pojoTypeInfo.getTypeAt(pojoTypeInfo.getFieldIndex(fieldNames[i])).getTypeClass(); } catch (IndexOutOfBoundsException e) { throw new IllegalArgumentException("Invalid field name: " + fieldNames[i]); } } this.pojoTypeClass = pojoTypeInfo.getTypeClass(); this.pojoTypeInfo = pojoTypeInfo; setFieldsGeneric(includedFieldsMask, classes); setOrderOfPOJOFields(fieldNames); }
result = new int[fieldNames.length]; for (int i = 0; i < fieldNames.length; i++) { int index = ((PojoTypeInfo) typeInfo).getFieldIndex(fieldNames[i]); if (index < 0) { throw new IllegalArgumentException(fieldNames[i] + " is not a field of type " + typeInfo);
private void configure(String lineDelimiter, String fieldDelimiter, PojoTypeInfo<OUT> pojoTypeInfo, String[] fieldNames, boolean[] includedFieldsMask) { if (includedFieldsMask == null) { includedFieldsMask = createDefaultMask(fieldNames.length); } for (String name : fieldNames) { if (name == null) { throw new NullPointerException("Field name must not be null."); } if (pojoTypeInfo.getFieldIndex(name) < 0) { throw new IllegalArgumentException("Field \"" + name + "\" not part of POJO type " + pojoTypeInfo.getTypeClass().getCanonicalName()); } } setDelimiter(lineDelimiter); setFieldDelimiter(fieldDelimiter); Class<?>[] classes = new Class<?>[fieldNames.length]; for (int i = 0; i < fieldNames.length; i++) { try { classes[i] = pojoTypeInfo.getTypeAt(pojoTypeInfo.getFieldIndex(fieldNames[i])).getTypeClass(); } catch (IndexOutOfBoundsException e) { throw new IllegalArgumentException("Invalid field name: " + fieldNames[i]); } } this.pojoTypeClass = pojoTypeInfo.getTypeClass(); this.pojoTypeInfo = pojoTypeInfo; setFieldsGeneric(includedFieldsMask, classes); setOrderOfPOJOFields(fieldNames); }
result = new int[fieldNames.length]; for (int i = 0; i < fieldNames.length; i++) { int index = ((PojoTypeInfo) typeInfo).getFieldIndex(fieldNames[i]); if (index < 0) { throw new IllegalArgumentException(fieldNames[i] + " is not a field of type " + typeInfo);
/** * Extracts the {@link InternalType}s from {@link PojoTypeInfo} corresponding to the given fieldNames. */ private static <OUT> InternalType[] extractTypeInfo(PojoTypeInfo<OUT> pojoTypeInfo, String[] fieldNames) { Preconditions.checkNotNull(pojoTypeInfo); Preconditions.checkNotNull(fieldNames); Preconditions.checkArgument(pojoTypeInfo.getArity() >= fieldNames.length); RowType rowType = (RowType) TypeConverters.createInternalTypeFromTypeInfo(pojoTypeInfo); InternalType[] fieldTypes = new InternalType[fieldNames.length]; for (int i = 0; i < fieldNames.length; ++i) { String fieldName = fieldNames[i]; Preconditions.checkNotNull(fieldName, "The field name cannot be null."); int fieldPos = pojoTypeInfo.getFieldIndex(fieldName); Preconditions.checkArgument(fieldPos >= 0, "Field \"" + fieldName + "\" is not a member of POJO class " + pojoTypeInfo.getTypeClass().getName()); fieldTypes[i] = rowType.getInternalTypeAt(fieldPos).toInternalType(); } return fieldTypes; }
PojoTypeInfo<?> pojoTypeInfo = (PojoTypeInfo) typeInfo; int fieldIndex = pojoTypeInfo.getFieldIndex(decomp.head);
PojoTypeInfo<?> pojoTypeInfo = (PojoTypeInfo) typeInfo; int fieldIndex = pojoTypeInfo.getFieldIndex(decomp.head);
PojoTypeInfo<?> pojoTypeInfo = (PojoTypeInfo) typeInfo; int fieldIndex = pojoTypeInfo.getFieldIndex(decomp.head);