001package com.hfg.setting; 002 003import java.util.HashMap; 004import java.util.Map; 005 006import com.hfg.util.BooleanUtil; 007import com.hfg.xml.XMLTag; 008 009//------------------------------------------------------------------------------ 010/** 011 * An XML-serializable float map setting. 012 * 013 * @author J. Alex Taylor, hairyfatguy.com 014 */ 015//------------------------------------------------------------------------------ 016// com.hfg XML/HTML Coding Library 017// 018// This library is free software; you can redistribute it and/or 019// modify it under the terms of the GNU Lesser General Public 020// License as published by the Free Software Foundation; either 021// version 2.1 of the License, or (at your option) any later version. 022// 023// This library is distributed in the hope that it will be useful, 024// but WITHOUT ANY WARRANTY; without even the implied warranty of 025// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 026// Lesser General Public License for more details. 027// 028// You should have received a copy of the GNU Lesser General Public 029// License along with this library; if not, write to the Free Software 030// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 031// 032// J. Alex Taylor, President, Founder, CEO, COO, CFO, OOPS hairyfatguy.com 033// [email protected] 034//------------------------------------------------------------------------------ 035 036public class BooleanMapSetting extends MapSettingImpl implements Setting<Map<String, Boolean>> 037{ 038 //########################################################################### 039 // CONSTRUCTORS 040 //########################################################################### 041 042 //--------------------------------------------------------------------------- 043 public BooleanMapSetting(String inName) 044 { 045 super(inName); 046 } 047 048 //--------------------------------------------------------------------------- 049 public BooleanMapSetting(String inName, Map<String, Boolean> inValue) 050 { 051 super(inName, inValue); 052 } 053 054 //--------------------------------------------------------------------------- 055 /** 056 * Copy constructor. 057 * @param inObj2 the BooleanMapSetting to clone 058 */ 059 public BooleanMapSetting(BooleanMapSetting inObj2) 060 { 061 this(inObj2.name(), inObj2.getValue() == null ? null : new HashMap<>(inObj2.getValue())); 062 } 063 064 //--------------------------------------------------------------------------- 065 public BooleanMapSetting(XMLTag inXMLTag) 066 { 067 super(inXMLTag); 068 } 069 070 //########################################################################### 071 // PUBLIC METHODS 072 //########################################################################### 073 074 //--------------------------------------------------------------------------- 075 public BooleanMapSetting setValue(Map<String, Boolean> inMap) 076 { 077 super.setObjectValue(inMap); 078 return this; 079 } 080 081 //--------------------------------------------------------------------------- 082 @SuppressWarnings("unchecked") 083 public void putStringValue(String inKey, String inValue) 084 { 085 Map<String, Boolean> map = getValue(); 086 map.put(inKey, inValue != null ? BooleanUtil.valueOf(inValue) : null); 087 } 088 089 //--------------------------------------------------------------------------- 090 @Override 091 @SuppressWarnings("unchecked") 092 public Map<String, Boolean> getValue() 093 { 094 return (Map<String, Boolean>) super.getObjectValue(); 095 } 096 097 //--------------------------------------------------------------------------- 098 @Override 099 public BooleanMapSetting clone() 100 { 101 return new BooleanMapSetting(this); 102 } 103}