1 /**
2 * Copyright 2005-2016 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.uif.util;
17
18 import java.util.HashMap;
19 import java.util.Map;
20 import java.util.Set;
21
22 /**
23 * Map implementation takes a <code>Set</code> of Strings and converts to Map
24 * where the string is the map key and value is the Boolean true, convenience
25 * collection for expression language.
26 *
27 * @author Kuali Rice Team (rice.collab@kuali.org)
28 */
29 public class BooleanMap extends HashMap<String, Boolean> {
30 private static final long serialVersionUID = 4042557657401395547L;
31
32 /**
33 * Copy constructor.
34 *
35 * @param m map to copy
36 */
37 public BooleanMap(Map<? extends String, ? extends Boolean> m) {
38 super(m);
39 }
40
41 /**
42 * Sets an initial value of {@link Boolean#TRUE} for a given provided set of keys.
43 *
44 * @param keys set of keys to map to {@link Boolean#TRUE}
45 */
46 public BooleanMap(Set<String> keys) {
47 super();
48
49 for (String key : keys) {
50 this.put(key, Boolean.TRUE);
51 }
52 }
53
54 /**
55 * Overrides the get method to return Boolean false if the key does not
56 * exist in the Map.
57 *
58 * {@inheritDoc}
59 */
60 @Override
61 public Boolean get(Object key) {
62 if (super.containsKey(key)) {
63 return super.get(key);
64 }
65
66 return Boolean.FALSE;
67 }
68
69 }