001/**
002 *  Unit-API - Units of Measurement API for Java
003 *  Copyright (c) 2005-2015, Jean-Marie Dautelle, Werner Keil, V2COM.
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-363 nor the names of its contributors may be used to endorse or promote products
017 *    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
032//import java.math.BigInteger;
033
034import javax.measure.Quantity;
035import javax.measure.Unit;
036
037import tec.uom.se.function.RationalConverter;
038
039/**
040 * Utility class holding prefixes used today in parts of India and Sri Lanka;
041 * based on grouping by two decimal places, rather than the
042 * three decimal places common in most parts of the world.</br><code> import static
043 * org.eclipse.uomo.units.TamilPrefix.*; // Static import. ... Unit<Pressure>
044 * ONDRU_PASCAL = ONDRU(PASCAL); 
045 * Unit<Length> PATHU_METER = PATHU(METER); </code>
046 * 
047 * @author <a href="mailto:werner@uom.systems">Werner Keil</a>
048 * @version 1.3, $Date: 2015-06-27 $
049 * @see <a
050 *      href="http://en.wikipedia.org/wiki/Tamil_units_of_measurement#Whole_numbers">Wikipedia:
051 *      Tamil units of measurement - Whole numbers</a>
052 */
053 // TODO while SE-specific, consider moving to a local module in uom-systems
054public abstract class TamilPrefix  {
055
056        /**
057         * <p>
058         * onRu
059         * </p>
060         * Returns the specified unit multiplied by the factor <code>1</code>
061         * 
062         * @param unit
063         *            any unit.
064         * @return <code>unit.times(1)</code>.
065         */
066        public static final <Q extends Quantity<Q>> Unit<Q> onRu(Unit<Q> unit) {
067                return unit;
068        }
069        
070        /**
071         * <p>
072         * patthu
073         * </p>
074         * Returns the specified unit multiplied by the factor
075         * <code>10<sup>1</sup></code>
076         * 
077         * @param unit
078         *            any unit.
079         * @return <code>unit.times(10)</code>.
080         */
081        public static final <Q extends Quantity<Q>> Unit<Q> patthu(Unit<Q> unit) {
082                return unit.transform(E1);
083        }
084
085        /**
086         * <p>
087         * nooRu
088         * </p>
089         * Returns the specified unit multiplied by the factor
090         * <code>10<sup>2</sup></code>
091         * 
092         * @param unit
093         *            any unit.
094         * @return <code>unit.times(100)</code>.
095         */
096        public static final <Q extends Quantity<Q>> Unit<Q> nooRu(Unit<Q> unit) {
097                return unit.transform(E2);
098        }
099
100        /**
101         * <p>
102         * aayiram
103         * </p>
104         * Returns the specified unit multiplied by the factor
105         * <code>10<sup>3</sup></code>
106         * 
107         * @param unit
108         *            any unit.
109         * @return <code>unit.times(1e3)</code>.
110         */
111        public static final <Q extends Quantity<Q>> Unit<Q> aayiram(Unit<Q> unit) {
112                return unit.transform(E3);
113        }
114
115        /**
116         * <p>
117         * nooRaayiram
118         * </p>
119         * Returns the specified unit multiplied by the factor
120         * <code>10<sup>5</sup></code>
121         * 
122         * @param unit
123         *            any unit.
124         * @return <code>unit.times(1e5)</code>.
125         */
126        public static final <Q extends Quantity<Q>> Unit<Q> nooRaayiram(Unit<Q> unit) {
127                return unit.transform(E5);
128        }
129
130        /**
131         * <p>
132         * thoLLunn
133         * </p>
134         * Returns the specified unit multiplied by the factor
135         * <code>10<sup>9</sup></code>
136         * 
137         * @param unit
138         *            any unit.
139         * @return <code>unit.times(1e9)</code>.
140         */
141        public static final <Q extends Quantity<Q>> Unit<Q> thoLLunn(Unit<Q> unit) {
142                return unit.transform(E9);
143        }
144
145        /**
146         * <p>
147         * eegiyam
148         * </p>
149         * Returns the specified unit multiplied by the factor
150         * <code>10<sup>12</sup></code>
151         * 
152         * @param unit
153         *            any unit.
154         * @return <code>unit.times(1e12)</code>.
155         */
156        public static final <Q extends Quantity<Q>> Unit<Q> eegiyam(Unit<Q> unit) {
157                return unit.transform(E12);
158        }
159
160        /**
161         * <p>
162         * neLai
163         * </p>
164         * Returns the specified unit multiplied by the factor
165         * <code>10<sup>15</sup></code>
166         * 
167         * @param unit
168         *            any unit.
169         * @return <code>unit.times(1e15)</code>.
170         */
171        public static final <Q extends Quantity<Q>> Unit<Q> neLai(Unit<Q> unit) {
172                return unit.transform(E15);
173        }
174
175        /**
176         * <p>
177         * iLanji
178         * </p>
179         * Returns the specified unit multiplied by the factor
180         * <code>10<sup>18</sup></code>
181         * 
182         * @param unit
183         *            any unit.
184         * @return <code>unit.times(1e18)</code>.
185         */
186        public static final <Q extends Quantity<Q>> Unit<Q> iLanji(Unit<Q> unit) {
187                return unit.transform(E18);
188        }
189
190        /**
191         * <p>
192         * veLLam
193         * </p>
194         * Returns the specified unit multiplied by the factor
195         * <code>10<sup>20</sup></code>
196         * 
197         * @param unit
198         *            any unit.
199         * @return <code>unit.times(1e20)</code>.
200         */
201        public static final <Q extends Quantity<Q>> Unit<Q> veLLam(Unit<Q> unit) {
202                return unit.transform(E20);
203        }
204        
205        /**
206         * <p>
207         * aambal
208         * </p>
209         * Returns the specified unit multiplied by the factor
210         * <code>10<sup>21</sup></code>
211         * 
212         * @param unit
213         *            any unit.
214         * @return <code>unit.times(1e21)</code>.
215         */
216        public static final <Q extends Quantity<Q>> Unit<Q> aambal(Unit<Q> unit) {
217                return unit.transform(E21);
218        }
219        
220        public static final class Sanskrit {
221                /**
222                 * <p>
223                 * ONDRU -one
224                 * </p>
225                 * Sanskrit translation for {@link #onRu}.
226                 */
227                public static final <Q extends Quantity<Q>> Unit<Q> ONDRU (Unit<Q> unit) {
228                        return onRu(unit);
229                }
230                
231                /**
232                 * <p>
233                 * PATHU -ten
234                 * </p>
235                 * Sanskrit translation for {@link #patthu}.
236                 */
237                public static final <Q extends Quantity<Q>> Unit<Q> PATHU(Unit<Q> unit) {
238                        return patthu(unit);
239                }
240        }
241
242        private static final RationalConverter E21 = RationalConverter.of(1e21d, 1d);
243        private static final RationalConverter E20 = RationalConverter.of(1e20d, 1d);
244        private static final RationalConverter E19 = RationalConverter.of(1e19d, 1d);
245        private static final RationalConverter E18 = RationalConverter.of(1e18d, 1d);
246        private static final RationalConverter E17 = RationalConverter.of(1e17d, 1d);
247        private static final RationalConverter E15 = RationalConverter.of(1e15d, 1d);
248        private static final RationalConverter E13 = RationalConverter.of(1e13d, 1d);
249        private static final RationalConverter E12 = RationalConverter.of(1e12d, 1d);
250        private static final RationalConverter E11 = RationalConverter.of(1e11d, 1d);
251        private static final RationalConverter E9 = RationalConverter.of(1e9d, 1d);
252        private static final RationalConverter E7 = RationalConverter.of(1e7d, 1d);
253        private static final RationalConverter E5 = RationalConverter.of(1e5d, 1d);
254        private static final RationalConverter E3 =RationalConverter.of(1e3d, 1d);
255        private static final RationalConverter E2 = RationalConverter.of(1e2d, 1d);
256        private static final RationalConverter E1 = RationalConverter.of(1e1d, 1d);
257        
258        /*
259         * static final RationalConverter E5 = new RationalConverter(
260                        BigInteger.TEN.pow(5), BigInteger.ONE);
261        // Holds prefix converters (optimization).
262        private static RationalConverter E21 = new RationalConverter(
263                        BigInteger.TEN.pow(21), BigInteger.ONE);
264        private static RationalConverter E20 = new RationalConverter(
265                        BigInteger.TEN.pow(20), BigInteger.ONE);
266        private static RationalConverter E18 = new RationalConverter(
267                        BigInteger.TEN.pow(18), BigInteger.ONE);
268        private static RationalConverter E15 = new RationalConverter(
269                        BigInteger.TEN.pow(15), BigInteger.ONE);
270        private static RationalConverter E12 = new RationalConverter(
271                        BigInteger.TEN.pow(12), BigInteger.ONE);
272        private static RationalConverter E9 = new RationalConverter(
273                        BigInteger.TEN.pow(9), BigInteger.ONE);
274        private static RationalConverter E3 = new RationalConverter(
275                        BigInteger.TEN.pow(3), BigInteger.ONE);
276        private static RationalConverter E2 = new RationalConverter(
277                        BigInteger.TEN.pow(2), BigInteger.ONE);
278        private static RationalConverter E1 = new RationalConverter(
279                        BigInteger.TEN.pow(1), BigInteger.ONE);
280                        */
281}