@Test void convert_to_optional_list() { DataTable table = parse("", "| 11.22 |", "| 255.999 |", "| |" ); List<Optional<BigDecimal>> expected = asList( Optional.of(new BigDecimal("11.22")), Optional.of(new BigDecimal("255.999")), Optional.empty() ); assertEquals(expected, converter.toList(table, OPTIONAL_BIG_DECIMAL)); }
@Override public <T> List<T> toList(DataTable dataTable, Type itemType) { requireNonNull(dataTable, "dataTable may not be null"); requireNonNull(itemType, "itemType may not be null"); if (dataTable.isEmpty()) { return emptyList(); } ListOrProblems<T> result = toListOrProblems(dataTable, itemType); if (result.hasList()) { return unmodifiableList(result.getList()); } throw listNoConverterDefined( itemType, result.getProblems() ); }
DataTableTypeRegistryTableConverter implements TableConverter { @Override public <T> List<T> toList(DataTable dataTable, Type itemType) { requireNonNull(dataTable, "dataTable may not be null"); requireNonNull(itemType, "itemType may not be null"); if (dataTable.isEmpty()) { return emptyList(); } ListOrProblems<T> result = toListOrProblems(dataTable, itemType); if (result.hasList()) { return unmodifiableList(result.getList()); } throw listNoConverterDefined( itemType, result.getProblems() ); } }
DataTableTypeRegistryTableConverter implements TableConverter { @Override public <T> List<T> toList(DataTable dataTable, Type itemType) { requireNonNull(dataTable, "dataTable may not be null"); requireNonNull(itemType, "itemType may not be null"); if (dataTable.isEmpty()) { return emptyList(); } ListOrProblems<T> result = toListOrProblems(dataTable, itemType); if (result.hasList()) { return unmodifiableList(result.getList()); } throw listNoConverterDefined( itemType, result.getProblems() ); } DataTableTypeRegistryTableConverter(DataTableTypeRegistry registry); }
DataTableTypeRegistryTableConverter implements TableConverter { @Override public <T> List<T> toList(DataTable dataTable, Type itemType) { requireNonNull(dataTable, "dataTable may not be null"); requireNonNull(itemType, "itemType may not be null"); if (dataTable.isEmpty()) { return emptyList(); } ListOrProblems<T> result = toListOrProblems(dataTable, itemType); if (result.hasList()) { return unmodifiableList(result.getList()); } throw listNoConverterDefined( itemType, result.getProblems() ); } DataTableTypeRegistryTableConverter(DataTableTypeRegistry registry); @Override T convert(DataTable dataTable, Type type); @Override @SuppressWarnings("unchecked") T convert(DataTable dataTable, Type type, boolean transposed); @Override List<T> toList(DataTable dataTable, Type itemType); @Override @SuppressWarnings("unchecked") List<List<T>> toLists(DataTable dataTable, Type itemType); @Override Map<K, V> toMap(DataTable dataTable, Type keyType, Type valueType); @Override @SuppressWarnings("unchecked") List<Map<K, V>> toMaps(DataTable dataTable, Type keyType, Type valueType); }
DataTableTypeRegistryTableConverter implements TableConverter { @Override public <T> List<T> toList(DataTable dataTable, Type itemType) { requireNonNull(dataTable, "dataTable may not be null"); requireNonNull(itemType, "itemType may not be null"); if (dataTable.isEmpty()) { return emptyList(); } ListOrProblems<T> result = toListOrProblems(dataTable, itemType); if (result.hasList()) { return unmodifiableList(result.getList()); } throw listNoConverterDefined( itemType, result.getProblems() ); } DataTableTypeRegistryTableConverter(DataTableTypeRegistry registry); @Override T convert(DataTable dataTable, Type type); @Override @SuppressWarnings("unchecked") T convert(DataTable dataTable, Type type, boolean transposed); @Override List<T> toList(DataTable dataTable, Type itemType); @Override @SuppressWarnings("unchecked") List<List<T>> toLists(DataTable dataTable, Type itemType); @Override Map<K, V> toMap(DataTable dataTable, Type keyType, Type valueType); @Override @SuppressWarnings("unchecked") List<Map<K, V>> toMaps(DataTable dataTable, Type keyType, Type valueType);  }