Coverage Report - org.kuali.rice.krad.keyvalues.MapValuesFinder
 
Classes in this File Line Coverage Branch Coverage Complexity
MapValuesFinder
0%
0/15
0%
0/4
1.429
 
 1  
 /**
 2  
  * Copyright 2005-2011 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.krad.keyvalues;
 17  
 
 18  
 import org.kuali.rice.core.api.util.ConcreteKeyValue;
 19  
 import org.kuali.rice.core.api.util.KeyValue;
 20  
 
 21  
 import java.util.ArrayList;
 22  
 import java.util.Collections;
 23  
 import java.util.HashMap;
 24  
 import java.util.List;
 25  
 import java.util.Map;
 26  
 
 27  
 /** a simple values finder that uses a map as the key/value source. */
 28  
 public class MapValuesFinder implements KeyValuesFinder {
 29  
 
 30  
     private Map<String, String> keyValues;
 31  
 
 32  0
     public MapValuesFinder(Map<String, String> keyValues) {
 33  0
         setKeyValues(keyValues);
 34  0
     }
 35  
 
 36  
     public void setKeyValues(Map<String, String> keyValues) {
 37  0
         if (keyValues == null) {
 38  0
             throw new IllegalArgumentException("keyValues was null");
 39  
         }
 40  0
         this.keyValues = Collections.unmodifiableMap(new HashMap<String, String>(keyValues));
 41  0
     }
 42  
 
 43  
     @Override
 44  
     public List<KeyValue> getKeyValues() {
 45  0
         final List<KeyValue> list = new ArrayList<KeyValue>();
 46  0
         for (Map.Entry<String, String> entry : keyValues.entrySet()) {
 47  0
             list.add(new ConcreteKeyValue(entry));
 48  
         }
 49  0
         return Collections.unmodifiableList(list);
 50  
     }
 51  
 
 52  
     @Override
 53  
     public List<KeyValue> getKeyValues(boolean includeActiveOnly) {
 54  0
         return getKeyValues();
 55  
     }
 56  
 
 57  
     @Override
 58  
     public Map<String, String> getKeyLabelMap() {
 59  0
         return keyValues;
 60  
     }
 61  
 
 62  
     @Override
 63  
     public String getKeyLabel(String key) {
 64  0
         return keyValues.get(key);
 65  
     }
 66  
 
 67  
     @Override
 68  
     public void clearInternalCache() {
 69  
         //do nothing
 70  0
     }
 71  
 }