001    /**
002     * Copyright 2005-2014 The Kuali Foundation
003     *
004     * Licensed under the Educational Community License, Version 2.0 (the "License");
005     * you may not use this file except in compliance with the License.
006     * You may obtain a copy of the License at
007     *
008     * http://www.opensource.org/licenses/ecl2.php
009     *
010     * Unless required by applicable law or agreed to in writing, software
011     * distributed under the License is distributed on an "AS IS" BASIS,
012     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013     * See the License for the specific language governing permissions and
014     * limitations under the License.
015     */
016    package org.kuali.rice.krad.uif.util;
017    
018    import java.util.HashMap;
019    import java.util.Set;
020    
021    /**
022     * Map implementation takes a <code>Set</code> of Strings and converts to Map
023     * where the string is the map key and value is the Boolean true, convenience
024     * collection for expression language
025     *
026     * @author Kuali Rice Team (rice.collab@kuali.org)
027     */
028    public class BooleanMap extends HashMap<String, Boolean> {
029        private static final long serialVersionUID = 4042557657401395547L;
030    
031        public BooleanMap(Set<String> keys) {
032            super();
033    
034            for (String key : keys) {
035                this.put(key, Boolean.TRUE);
036            }
037        }
038    
039        /**
040         * Overrides the get method to return Boolean false if the key does not
041         * exist in the Map
042         *
043         * @see java.util.HashMap#get(java.lang.Object)
044         */
045        @Override
046        public Boolean get(Object key) {
047            if (super.containsKey(key)) {
048                return super.get(key);
049            }
050    
051            return Boolean.FALSE;
052        }
053    
054    }