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