Coverage Report - org.kuali.rice.kew.api.doctype.DocumentTypePolicyMapAdapter
 
Classes in this File Line Coverage Branch Coverage Complexity
DocumentTypePolicyMapAdapter
0%
0/14
0%
0/10
3.5
 
 1  
 /*
 2  
  * Copyright 2007-2009 The Kuali Foundation
 3  
  *
 4  
  * Licensed under the Educational Community License, Version 2.0 (the "License");
 5  
  * you may not use this file except in compliance with the License.
 6  
  * You may obtain a copy of the License at
 7  
  *
 8  
  * http://www.opensource.org/licenses/ecl2.php
 9  
  *
 10  
  * Unless required by applicable law or agreed to in writing, software
 11  
  * distributed under the License is distributed on an "AS IS" BASIS,
 12  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13  
  * See the License for the specific language governing permissions and
 14  
  * limitations under the License.
 15  
  */
 16  
 package org.kuali.rice.kew.api.doctype;
 17  
 
 18  
 import org.kuali.rice.core.api.util.jaxb.StringMapEntry;
 19  
 import org.kuali.rice.core.api.util.jaxb.StringMapEntryList;
 20  
 
 21  
 import javax.xml.bind.annotation.adapters.XmlAdapter;
 22  
 import java.util.ArrayList;
 23  
 import java.util.HashMap;
 24  
 import java.util.List;
 25  
 import java.util.Map;
 26  
 
 27  
 /**
 28  
  * TODO...
 29  
  * 
 30  
  * @author Kuali Rice Team (kuali-rice@googlegroups.com)
 31  
  *
 32  
  */
 33  0
 class DocumentTypePolicyMapAdapter extends XmlAdapter<StringMapEntryList, Map<DocumentTypePolicy, String>> {
 34  
 
 35  
         @Override
 36  
         public StringMapEntryList marshal(Map<DocumentTypePolicy, String> map) {
 37  0
             List<StringMapEntry> entries = new ArrayList<StringMapEntry>();
 38  0
             if (map != null) {
 39  0
                 for (DocumentTypePolicy policy : map.keySet()) {
 40  0
                     entries.add(new StringMapEntry(policy.getCode(), map.get(policy)));
 41  
                 }
 42  
             }
 43  0
             return new StringMapEntryList(entries);
 44  
         }
 45  
 
 46  
         @Override
 47  
         public Map<DocumentTypePolicy, String> unmarshal(StringMapEntryList entryList) {
 48  0
             Map<DocumentTypePolicy, String> policies = new HashMap<DocumentTypePolicy, String>();
 49  0
             if (entryList != null) {
 50  0
                 for (StringMapEntry entry : entryList.getEntries()) {
 51  0
                     DocumentTypePolicy policy = DocumentTypePolicy.fromCode(entry.getKey());
 52  
                     // if the policy value comes back as null, that means we recieved a policy that we
 53  
                     // don't understand...ignore it
 54  0
                     if (policy != null) {
 55  0
                         policies.put(policy, entry.getValue());
 56  
                     }
 57  0
                 }
 58  
             }
 59  0
             return policies;
 60  
         }
 61  
         
 62  
 }