From 10e83dff8f6d6bec758ee5861106e44861bd49f7 Mon Sep 17 00:00:00 2001 From: Otavio Santana Date: Tue, 9 Mar 2021 21:53:18 +0000 Subject: [PATCH] updates the column entity API --- .../src/main/java/jakarta/nosql/column/ColumnEntity.java | 8 ++++---- .../nosql/communication/column/ColumnEntityTest.java | 9 +++++++-- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/api/communication/communication-column/src/main/java/jakarta/nosql/column/ColumnEntity.java b/api/communication/communication-column/src/main/java/jakarta/nosql/column/ColumnEntity.java index 34467a7e1..db415212b 100644 --- a/api/communication/communication-column/src/main/java/jakarta/nosql/column/ColumnEntity.java +++ b/api/communication/communication-column/src/main/java/jakarta/nosql/column/ColumnEntity.java @@ -143,7 +143,7 @@ static ColumnEntity of(String name, List 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 */ @@ -154,11 +154,11 @@ static ColumnEntity of(String name, List 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 find(String columnName, TypeSupplier type); + Optional find(String columnName, TypeSupplier type); /** * Returns the number of elements in this list. diff --git a/tck/communication-tck/communication-tck-column/src/main/java/jakarta/nosql/communication/column/ColumnEntityTest.java b/tck/communication-tck/communication-tck-column/src/main/java/jakarta/nosql/communication/column/ColumnEntityTest.java index 1164d6c10..ef8765d53 100644 --- a/tck/communication-tck/communication-tck-column/src/main/java/jakarta/nosql/communication/column/ColumnEntityTest.java +++ b/tck/communication-tck/communication-tck-column/src/main/java/jakarta/nosql/communication/column/ColumnEntityTest.java @@ -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; @@ -118,7 +119,9 @@ public void shouldNotFindValue() { public void shouldFindTypeSupplier() { Column column = Column.of("name", "name"); ColumnEntity entity = ColumnEntity.of("entity", singletonList(column)); - List names = entity.find("name", new TypeReference>() {}); + List names = entity.find("name", new TypeReference>() { + }) + .orElse(Collections.emptyList()); Assertions.assertNotNull(names); Assertions.assertFalse(names.isEmpty()); } @@ -127,7 +130,9 @@ public void shouldFindTypeSupplier() { public void shouldNotFindTypeSupplier() { Column column = Column.of("name", "name"); ColumnEntity entity = ColumnEntity.of("entity", singletonList(column)); - List names = entity.find("not_found", new TypeReference>() {}); + List names = entity.find("not_found", new TypeReference>() { + }) + .orElse(Collections.emptyList()); Assertions.assertNotNull(names); Assertions.assertTrue(names.isEmpty()); }