001package com.hfg.units; 002 003 004import java.util.HashMap; 005import java.util.Map; 006 007import com.hfg.util.StringUtil; 008 009//------------------------------------------------------------------------------ 010/** 011 Enumeration of amount of substance units. 012 <div> 013 @author J. Alex Taylor, hairyfatguy.com 014 </div> 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 AmountOfSubstanceUnit extends Unit 038{ 039 private static Map<String, AmountOfSubstanceUnit> sLookupMap = new HashMap<>(); 040 041 public static final AmountOfSubstanceUnit mole = new AmountOfSubstanceUnit(MeasurementSystem.SI, "mole", "mol"); 042 /** 043 * The mole equivalents of an acid or base is determined by calculating the number of H+ or OH- ions per molecule. 044 */ 045 public static final AmountOfSubstanceUnit mole_equivalent = new AmountOfSubstanceUnit(MeasurementSystem.SI, "mole equivalent", ""); 046 047 048 //--------------------------------------------------------------------------- 049 private AmountOfSubstanceUnit(MeasurementSystem inSystem, String inName, String inAbbrev) 050 { 051 super(inSystem, QuantityType.AMOUNT_OF_SUBSTANCE, inName, inAbbrev); 052 053 sLookupMap.put(name(), this); 054 sLookupMap.put(getAbbrev(), this); 055 } 056 057 058 059 //--------------------------------------------------------------------------- 060 public static AmountOfSubstanceUnit valueOf(String inString) 061 { 062 return StringUtil.isSet(inString) ? sLookupMap.get(inString) : null; 063 } 064 065}