Skip to content

Commit

Permalink
updates the column entity API
Browse files Browse the repository at this point in the history
  • Loading branch information
otaviojava committed Mar 9, 2021
1 parent c7e9e05 commit 10e83df
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
Expand Up @@ -143,7 +143,7 @@ static ColumnEntity of(String name, List<Column> columns) {
* It is a alias to {@link Value#get(Class)}
*
* @param columnName a name of a column
* @param type the type to convert the value
* @param type the type to convert the value
* @return an {@link Optional} instance with the result
* @throws NullPointerException when there are null parameters
*/
Expand All @@ -154,11 +154,11 @@ static ColumnEntity of(String name, List<Column> columns) {
* It is a alias to {@link Value#get(TypeSupplier)}
*
* @param columnName a name of a column
* @param type the type to convert the value
* @return a new instance converted to informed class
* @param type the type to convert the value
* @return an {@link Optional} instance with the result
* @throws NullPointerException when there are null parameters
*/
<T> T find(String columnName, TypeSupplier<T> type);
<T> Optional<T> find(String columnName, TypeSupplier<T> type);

/**
* Returns the number of elements in this list.
Expand Down
Expand Up @@ -26,6 +26,7 @@

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Optional;
Expand Down Expand Up @@ -118,7 +119,9 @@ public void shouldNotFindValue() {
public void shouldFindTypeSupplier() {
Column column = Column.of("name", "name");
ColumnEntity entity = ColumnEntity.of("entity", singletonList(column));
List<String> names = entity.find("name", new TypeReference<List<String>>() {});
List<String> names = entity.find("name", new TypeReference<List<String>>() {
})
.orElse(Collections.emptyList());
Assertions.assertNotNull(names);
Assertions.assertFalse(names.isEmpty());
}
Expand All @@ -127,7 +130,9 @@ public void shouldFindTypeSupplier() {
public void shouldNotFindTypeSupplier() {
Column column = Column.of("name", "name");
ColumnEntity entity = ColumnEntity.of("entity", singletonList(column));
List<String> names = entity.find("not_found", new TypeReference<List<String>>() {});
List<String> names = entity.find("not_found", new TypeReference<List<String>>() {
})
.orElse(Collections.emptyList());
Assertions.assertNotNull(names);
Assertions.assertTrue(names.isEmpty());
}
Expand Down

0 comments on commit 10e83df

Please sign in to comment.