@Test public void testConvertMultiValue() { assertNull(RecordReaderUtils.convertMultiValue(null)); assertNull(RecordReaderUtils.convertMultiValue(Collections.emptyList())); assertNull(RecordReaderUtils.convertMultiValue(Collections.singletonList(null))); assertNull(RecordReaderUtils.convertMultiValue(Collections.singletonList(""))); assertNull(RecordReaderUtils.convertMultiValue(Arrays.asList(null, ""))); assertEquals(RecordReaderUtils.convertMultiValue(Arrays.asList(null, "", 123)), new Object[]{123}); }
public static @Nullable Object convertMultiValue(@Nullable Collection values) { if (values == null || values.isEmpty()) { return null; } int numValues = values.size(); Object[] array = new Object[numValues]; int index = 0; for (Object value : values) { Object convertedValue = convertSingleValue(value); if (convertedValue != null && !convertedValue.toString().equals("")) { array[index++] = convertedValue; } } if (index == numValues) { return array; } else if (index == 0) { return null; } else { return Arrays.copyOf(array, index); } }
RecordReaderUtils { public static @Nullable Object convertMultiValue(@Nullable Collection values) { if (values == null || values.isEmpty()) { return null; } int numValues = values.size(); Object[] array = new Object[numValues]; int index = 0; for (Object value : values) { Object convertedValue = convertSingleValue(value); if (convertedValue != null && !convertedValue.toString().equals("")) { array[index++] = convertedValue; } } if (index == numValues) { return array; } else if (index == 0) { return null; } else { return Arrays.copyOf(array, index); } } }
RecordReaderUtils { public static @Nullable Object convertMultiValue(@Nullable Collection values) { if (values == null || values.isEmpty()) { return null; } int numValues = values.size(); Object[] array = new Object[numValues]; int index = 0; for (Object value : values) { Object convertedValue = convertSingleValue(value); if (convertedValue != null && !convertedValue.toString().equals("")) { array[index++] = convertedValue; } } if (index == numValues) { return array; } else if (index == 0) { return null; } else { return Arrays.copyOf(array, index); } } private  RecordReaderUtils(); }
RecordReaderUtils { public static @Nullable Object convertMultiValue(@Nullable Collection values) { if (values == null || values.isEmpty()) { return null; } int numValues = values.size(); Object[] array = new Object[numValues]; int index = 0; for (Object value : values) { Object convertedValue = convertSingleValue(value); if (convertedValue != null && !convertedValue.toString().equals("")) { array[index++] = convertedValue; } } if (index == numValues) { return array; } else if (index == 0) { return null; } else { return Arrays.copyOf(array, index); } } private  RecordReaderUtils(); static BufferedReader getBufferedReader(File dataFile); static BufferedInputStream getBufferedInputStream(File dataFile); static InputStream getInputStream(File dataFile); static @Nullable Object convert(@Nullable Object value); static @Nullable Object convertSingleValue(@Nullable Object value); static @Nullable Object convertMultiValue(@Nullable Collection values); }
RecordReaderUtils { public static @Nullable Object convertMultiValue(@Nullable Collection values) { if (values == null || values.isEmpty()) { return null; } int numValues = values.size(); Object[] array = new Object[numValues]; int index = 0; for (Object value : values) { Object convertedValue = convertSingleValue(value); if (convertedValue != null && !convertedValue.toString().equals("")) { array[index++] = convertedValue; } } if (index == numValues) { return array; } else if (index == 0) { return null; } else { return Arrays.copyOf(array, index); } } private  RecordReaderUtils(); static BufferedReader getBufferedReader(File dataFile); static BufferedInputStream getBufferedInputStream(File dataFile); static InputStream getInputStream(File dataFile); static @Nullable Object convert(@Nullable Object value); static @Nullable Object convertSingleValue(@Nullable Object value); static @Nullable Object convertMultiValue(@Nullable Collection values); static final String GZIP_FILE_EXTENSION; }