Skip to content

Commit 6ba7380

Browse files
committed
Update BeanAdapter.
1 parent 951322c commit 6ba7380

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

kilo-client/src/main/java/org/httprpc/kilo/beans/BeanAdapter.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@
5858
import static org.httprpc.kilo.util.Optionals.*;
5959

6060
/**
61-
* Provides access to Java bean properties via the {@link Map} interface.
61+
* Provides access to Java bean properties and record components via the
62+
* {@link Map} interface.
6263
*/
6364
public class BeanAdapter extends AbstractMap<String, Object> {
6465
/**
@@ -564,9 +565,6 @@ public Entry<String, Object> next() {
564565
* <p>If the value is an array, it is wrapped in a {@link List} that will
565566
* recursively adapt the array's elements.</p>
566567
*
567-
* <p>If the value is a {@link Record}, it is wrapped in a {@link Map} that
568-
* will recursively adapt the record's fields.</p>
569-
*
570568
* <p>If the value is an {@link Iterable}, it is wrapped in a {@link List}
571569
* that will recursively adapt the iterable's elements. If the iterable
572570
* implements {@link Collection}, the adapter will support the
@@ -651,8 +649,7 @@ public static Object adapt(Object value) {
651649
* <p>If none of the previous conditions apply, the provided value is
652650
* assumed to be a map. If the if the target type is a {@link Record}, the
653651
* resulting value is instantiated via the type's canonical constructor
654-
* using the entries in the map. Otherwise, the target type is assumed to
655-
* be a bean:</p>
652+
* using the entries in the map. Otherwise:</p>
656653
*
657654
* <ul>
658655
* <li>If the type is an interface, the return value is a proxy that maps

kilo-client/src/test/java/org/httprpc/kilo/beans/BeanAdapterTest.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,10 @@ public void testInvalidPut() {
161161
assertThrows(IllegalArgumentException.class, () -> beanAdapter.put("date", "xyz"));
162162

163163
assertThrows(UnsupportedOperationException.class, () -> beanAdapter.put("foo", 101));
164+
165+
var recordAdapter = new BeanAdapter(new TestRecord(1, 2.0, "three", null));
166+
167+
assertThrows(UnsupportedOperationException.class, () -> recordAdapter.put("localDate", LocalDate.now()));
164168
}
165169

166170
@Test

0 commit comments

Comments
 (0)