You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
var average = mathServiceProxy.getAverage(listOf(1.0, 2.0, 3.0, 4.0, 5.0)); // 3.0
452
452
```
453
453
454
-
The [`Name`](#custom-parameter-names) and [`Required`](#required-parameters) annotations may also be applied to proxy method parameters. The `WebServiceProxy.Configuration` annotation can be used to further customize request processing.
454
+
The [`Required`](#required-parameters) and [`Name`](#custom-parameter-names) annotations may also be applied to proxy method parameters. The `WebServiceProxy.Configuration` annotation can be used to further customize request processing.
455
455
456
456
Path variables and body content are handled as described for [`WebService`](#webservice). Body parameters are required for `POST` and `PUT` methods. A body parameter of type `Void` may be used to indicate that a method does not accept a body.
Note that concrete types are coerced "eagerly" (before the `coerce()` method returns), while interfaces are coerced "lazily" (when a property is accessed).
631
631
632
-
### Required Properties
633
-
The `Required` annotation introduced [previously](#required-parameters) can also be used to indicate that a property must contain a value. For example:
634
-
635
-
```java
636
-
publicclassVehicle {
637
-
privateString manufacturer;
638
-
privateInteger year;
639
-
640
-
@Required
641
-
publicStringgetManufacturer() {
642
-
return manufacturer;
643
-
}
644
-
645
-
publicvoidsetManufacturer(Stringmanufacturer) {
646
-
this.manufacturer = manufacturer;
647
-
}
648
-
649
-
@Required
650
-
publicIntegergetYear() {
651
-
return year;
652
-
}
653
-
654
-
publicvoidsetYear(Integeryear) {
655
-
this.year = year;
656
-
}
657
-
}
658
-
```
659
-
660
-
Because both "manufacturer" and "year" are required, an attempt to coerce an empty map to a `Vehicle` instance would produce an `IllegalArgumentException`:
661
-
662
-
```java
663
-
var vehicle =BeanAdapter.coerce(mapOf(), Vehicle.class); // throws
664
-
```
665
-
666
-
Additionally, although the annotation will not prevent a caller from programmatically assigning a `null` value to either property, attempting to dynamically set an invalid value will generate an `IllegalArgumentException`:
Similarly, attempting to dynamically access an invalid value will result in an `UnsupportedOperationException`:
677
-
678
-
```java
679
-
vehicleAdapter.get("manufacturer"); // throws
680
-
```
681
-
682
-
### Custom Property Names
683
-
The `Name` annotation introduced [previously](#custom-parameter-names) can also be used with bean properties. For example:
684
-
685
-
```java
686
-
publicclassPerson {
687
-
privateString firstName =null;
688
-
privateString lastName =null;
689
-
690
-
@Name("first_name")
691
-
publicStringgetFirstName() {
692
-
return firstName;
693
-
}
694
-
695
-
publicvoidsetFirstName(StringfirstName) {
696
-
this.firstName = firstName;
697
-
}
698
-
699
-
@Name("last_name")
700
-
publicStringgetLastName() {
701
-
return lastName;
702
-
}
703
-
704
-
publicvoidsetLastName(StringlastName) {
705
-
this.lastName = lastName;
706
-
}
707
-
}
708
-
```
632
+
The `Required` and `Name` annotations introduced previously can also be used with bean properties.
709
633
710
634
## QueryBuilder and ResultSetAdapter
711
635
The `QueryBuilder` class provides support for programmatically constructing and executing SQL queries. For example, given the following tables (adapted from the MySQL tutorial):
0 commit comments