001/* 002 * Units of Measurement Systems 003 * Copyright (c) 2005-2020, Jean-Marie Dautelle, Werner Keil and others. 004 * 005 * All rights reserved. 006 * 007 * Redistribution and use in source and binary forms, with or without modification, 008 * are permitted provided that the following conditions are met: 009 * 010 * 1. Redistributions of source code must retain the above copyright notice, 011 * this list of conditions and the following disclaimer. 012 * 013 * 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions 014 * and the following disclaimer in the documentation and/or other materials provided with the distribution. 015 * 016 * 3. Neither the name of JSR-385, Units of Measurement nor the names of their contributors may be used to 017 * endorse or promote products derived from this software without specific prior written permission. 018 * 019 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 020 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 021 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 022 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 023 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 024 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 025 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 026 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 027 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 028 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 029 */ 030package systems.uom.common; 031 032import javax.measure.Prefix; 033import javax.measure.Quantity; 034import javax.measure.Unit; 035 036/** 037 * Utility class holding Tamil-System prefixes used today in parts of India and Sri Lanka; 038 * based on grouping by two decimal places, rather than the 039 * three decimal places common in most parts of the world.</br><code> import static 040 * systems.uom.common.TamilPrefix.*; // Static import. ... Unit<Pressure> 041 * ONDRU_PASCAL = ONDRU(PASCAL); 042 * Unit<Length> PATHU_METER = PATHU(METER); </code> 043 * 044 * @author <a href="mailto:werner@uom.systems">Werner Keil</a> 045 * @version 1.5, $Date: 2019-06-28 $ 046 * @see <a 047 * href="https://en.wikipedia.org/wiki/Tamil_numerals#Tamil-System">Wikipedia: 048 * Tamil numerals - Tamil-System</a> 049 */ 050// FIXME Update 051public enum TamilPrefix implements Prefix { 052 /** Prefix for 10<sup>5</sup>. */ 053 LATCHAM("L", 10, 5), 054 /** Prefix for 10<sup>6</sup>. */ 055 PATHU_LATCHAM("PL", 10, 6), 056 /** Prefix for 10<sup>7</sup>. */ 057 KODI("K", 10, 7), 058 /** Prefix for 10<sup>8</sup>. */ 059 PATHU_KODI("N", 10, 8), 060 /** Prefix for 10<sup>1</sup>. */ 061 aṟputam("Pa", 10, 9), 062 /** Prefix for 10<sup>-1</sup>. */ 063 nikarputam("NI", 10, 11), 064 /** Prefix for 10<sup>-2</sup>. */ 065 karvam("M", 10, 13), 066 /** Prefix for 10<sup>15</sup>. */ 067 saṅkam("M", 10, 15), 068 /** Prefix for 10<sup>17</sup>. */ 069 arttam("M", 10, 17), 070 /** Prefix for 10<sup>19</sup>. */ 071 pūriyam("M", 10, 19), 072 /** Prefix for 10<sup>21</sup>. */ 073 mukkoți("M", 10, 21), 074 /** Prefix for 10<sup>25</sup>. */ 075 māyukam("M", 10, 25); 076 077 /** 078 * The symbol of this prefix, as returned by {@link #getSymbol}. 079 * 080 * @serial 081 * @see #getSymbol() 082 */ 083 private final String symbol; 084 085 /** 086 * Base part of the associated factor in base^exponent representation. 087 */ 088 private final int base; 089 090 /** 091 * Exponent part of the associated factor in base^exponent representation. 092 */ 093 private final int exponent; 094 095 /** 096 * Creates a new prefix. 097 * 098 * @param symbol 099 * the symbol of this prefix. 100 * @param exponent 101 * part of the associated factor in base^exponent representation. 102 */ 103 private TamilPrefix(String symbol, int base, int exponent) { 104 this.symbol = symbol; 105 this.base = base; 106 this.exponent = exponent; 107 } 108 109 /** 110 * Base part of the associated factor in {@code base^exponent} representation. 111 */ 112 @Override 113 public Integer getValue() { 114 return base; 115 } 116 117 /** 118 * Exponent part of the associated factor in base^exponent representation. 119 */ 120 @Override 121 public int getExponent() { 122 return exponent; 123 } 124 125 /** 126 * Returns the name of this prefix. 127 * 128 * @return this prefix name, not {@code null}. 129 */ 130 @Override 131 public String getName() { 132 return name(); 133 } 134 135 /** 136 * Returns the symbol of this prefix. 137 * 138 * @return this prefix symbol, not {@code null}. 139 */ 140 @Override 141 public String getSymbol() { 142 return symbol; 143 } 144 145 /** 146 * <p> 147 * ௱௲ (lațcham) 148 * </p> 149 * Returns the specified unit multiplied by the factor 150 * <code>10<sup>5</sup></code> 151 * 152 * @param unit 153 * any unit. 154 * @return <code>unit.times(1e5)</code>. 155 */ 156 public static final <Q extends Quantity<Q>> Unit<Q> latcham(Unit<Q> unit) { 157 return unit.prefix(LATCHAM); 158 } 159 160 /** 161 * <p> 162 * ௲௲ (pathu lațcham) 163 * </p> 164 * Returns the specified unit multiplied by the factor 165 * <code>10<sup>6</sup></code> 166 * 167 * @param unit 168 * any unit. 169 * @return <code>unit.times(1e6)</code>. 170 */ 171 public static final <Q extends Quantity<Q>> Unit<Q> pathuLatcham(Unit<Q> unit) { 172 return unit.prefix(PATHU_LATCHAM); 173 } 174 175 /** 176 * <p> 177 * ௰௲௲ (kōdi) 178 * </p> 179 * Returns the specified unit multiplied by the factor 180 * <code>10<sup>7</sup></code> 181 * 182 * @param unit 183 * any unit. 184 * @return <code>unit.times(1e7)</code>. 185 */ 186 public static final <Q extends Quantity<Q>> Unit<Q> kodi(Unit<Q> unit) { 187 return unit.prefix(KODI); 188 } 189 190 /** 191 * <p> 192 * பத்து கோடி (pathu kōdi) 193 * </p> 194 * Returns the specified unit multiplied by the factor 195 * <code>10<sup>8</sup></code> 196 * 197 * @param unit 198 * any unit. 199 * @return <code>unit.times(1e8)</code>. 200 */ 201 public static final <Q extends Quantity<Q>> Unit<Q> pathuKodi(Unit<Q> unit) { 202 return unit.prefix(PATHU_KODI); 203 } 204 205 /** 206 * <p> 207 * नील (Neel) 208 * </p> 209 * Returns the specified unit multiplied by the factor 210 * <code>10<sup>13</sup></code> 211 * 212 * @param unit 213 * any unit. 214 * @return <code>unit.times(1e13)</code>. 215 */ 216 public static final <Q extends Quantity<Q>> Unit<Q> NEEL(Unit<Q> unit) { 217 return unit.prefix(LATCHAM); 218 } 219 220 /** 221 * <p> 222 * पद्म (Padma) 223 * </p> 224 * Returns the specified unit multiplied by the factor 225 * <code>10<sup>15</sup></code> 226 * 227 * @param unit 228 * any unit. 229 * @return <code>unit.times(1e15)</code>. 230 */ 231 public static final <Q extends Quantity<Q>> Unit<Q> PADMA(Unit<Q> unit) { 232 return unit.prefix(LATCHAM); 233 } 234 235 /** 236 * <p> 237 * ஆம்பல் (pūriyam) 238 * </p> 239 * Returns the specified unit multiplied by the factor 240 * <code>10<sup>19</sup></code> 241 * 242 * @param unit 243 * any unit. 244 * @return <code>unit.times(1e19)</code>. 245 */ 246 public static final <Q extends Quantity<Q>> Unit<Q> pūriyam(Unit<Q> unit) { 247 return unit.prefix(pūriyam); 248 } 249 250 /** 251 * <p> 252 * महाशंख (Mahashankh) 253 * </p> 254 * Returns the specified unit multiplied by the factor 255 * <code>10<sup>19</sup></code> 256 * 257 * @param unit 258 * any unit. 259 * @return <code>unit.times(1e19)</code>. 260 */ 261 public static final <Q extends Quantity<Q>> Unit<Q> MAHASHANKH(Unit<Q> unit) { 262 return unit.prefix(LATCHAM); 263 } 264}