Changes between Version 5 and Version 6 of ExampleUsingOwnConceteTypes
- Timestamp:
- 05/08/07 10:07:31 (18 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
ExampleUsingOwnConceteTypes
v5 v6 70 70 == Using own types in Collections and Maps == 71 71 72 When turning generics into thier class representation, java runs a so called type erasure, reducing a Collection<Param> to a simple Collection. 73 Thus, the XML-RPC runtime system cannot determine the content type of this collection unless the user places an extra hint using the @Contains annotation. 72 Collections, maps and arrays using the user-defined type as content can also be used out-of-the-box. 74 73 75 74 {{{ 76 // DOES NOT WORK: Map<String,Param> will be reduced to Map, Collection<Param> will be reduced to Collection75 // WORKS! 77 76 public interface Api 78 77 { … … 80 79 81 80 void passManyParams( Collection<Param> params ); 82 }83 }}}84 81 85 Place a @Contains in front of the method to annotate a return type. Place it before a formal parameter 86 to annotate method parameters. 87 {{{ 88 // WORKS! 89 public interface Api 90 { 91 @Contains(Param.class) 92 Map<String,Param> returnMyParamInMap(); 93 94 void passManyParams( @Contains(Param.class) 95 Collection<Param> params ); 82 void passParamsInArray( Param[] params ); 96 83 } 97 84 }}}