Changes between Version 5 and Version 6 of ExampleUsingOwnConceteTypes


Ignore:
Timestamp:
05/08/07 10:07:31 (18 years ago)
Author:
lauer
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • ExampleUsingOwnConceteTypes

    v5 v6  
    7070== Using own types in Collections and Maps == 
    7171 
    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. 
     72Collections, maps and arrays using the user-defined type as content can also be used out-of-the-box. 
    7473 
    7574{{{ 
    76 // DOES NOT WORK: Map<String,Param> will be reduced to Map, Collection<Param> will be reduced to Collection 
     75// WORKS! 
    7776public interface Api 
    7877{ 
     
    8079     
    8180    void passManyParams( Collection<Param> params ); 
    82 } 
    83 }}} 
    8481 
    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 ); 
    9683} 
    9784}}}