Coverage Report - org.kuali.rice.core.jaxb.ImmutableCollectionAdapter
 
Classes in this File Line Coverage Branch Coverage Complexity
ImmutableCollectionAdapter
0%
0/3
N/A
1
 
 1  
 package org.kuali.rice.core.jaxb;
 2  
 
 3  
 import javax.xml.bind.annotation.adapters.XmlAdapter;
 4  
 import java.util.Arrays;
 5  
 import java.util.Collection;
 6  
 import java.util.Collections;
 7  
 
 8  
 /**
 9  
  * Handles JAXB mapping that ensures that any Collection created from unmarshalled XML will be immutable.
 10  
  */
 11  0
 public class ImmutableCollectionAdapter extends XmlAdapter<Object[], Collection<?>> {
 12  
 
 13  
     /**
 14  
      * Returns an immutable Collection when a Collection is meant to be unmarshalled from XML.  This is done to ensure service
 15  
      * contracts, which are to return immutable objects, also return immutable Collections when an XML sequence is returned
 16  
      * via a remote SOAP call.
 17  
      *
 18  
      * @param objects an array of Objects collected from XML to be transformed into an immutable Collection
 19  
      * @return An immutable Collection
 20  
      * @throws Exception
 21  
      */
 22  
     @Override
 23  
     public Collection<?> unmarshal(Object[] objects) throws Exception {
 24  0
         return Collections.unmodifiableCollection(Arrays.asList(objects));
 25  
     }
 26  
 
 27  
     /**
 28  
      * Creates an array of Object[] from a passed in List for JAXB marshalling. There is no requirement of what kind of
 29  
      * List is used when marshalling to XML.
 30  
      *
 31  
      * @param objects
 32  
      * @return The same List object that was passed in
 33  
      * @throws Exception
 34  
      */
 35  
     @Override
 36  
     public Object[] marshal(Collection<?> objects) throws Exception {
 37  0
         return objects.toArray();
 38  
     }
 39  
 }
 40