001/*
002 * Units of Measurement Systems
003 * Copyright (c) 2005-2021, 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.historic;
031
032import javax.measure.Prefix;
033import javax.measure.Quantity;
034import javax.measure.Unit;
035
036/**
037 * Utility class holding  traditional numbers of the Vedic numbering system used in the Valmiki Ramayana<br>
038 * <code>Unit&lt;Length&gt; KOTI_METRE = KOTI(METRE); </code>
039 * 
040 * @author <a href="mailto:werner@uom.systems">Werner Keil</a>
041 * @version 0.3, $Date: 2020-01-11 $
042 * @see <a
043 *      href="https://en.wikipedia.org/wiki/Indian_numbering_system#Vedic_numbering_systems">Wikipedia: Indian numbering system - Vedic numbering systems</a>
044 * @draft 2.0
045 */
046public enum VedicPrefix implements Prefix {
047    /** Prefix for 10<sup>24</sup>. */
048        EK("E", 1, 1),
049    /** Prefix for 10<sup>21</sup>. */
050        DAS("D", 10, 1),
051    /** Prefix for 10<sup>18</sup>. */
052        SAU("S", 10, 2),
053    /** Prefix for 10<sup>15</sup>. */
054        SAHASR("SA", 10, 3),
055    /** Prefix for 10<sup>12</sup>. */
056        LAKH("Lk", 10, 5),
057    /** Prefix for 10<sup>9</sup>. */
058        CRORE("cr", 10, 7),
059    /** Prefix for 10<sup>6</sup>. */
060        ARAWB("A", 10, 9),
061    /** Prefix for 10<sup>3</sup>. */
062        KHARAWB("K", 10, 11),
063    /** Prefix for 10<sup>2</sup>. */
064        NEEL("N", 10, 13),
065    /** Prefix for 10<sup>1</sup>. */
066        PADMA("Pa", 10, 15),
067    /** Prefix for 10<sup>-1</sup>. */
068        SHANKH("SH", 10, 17),
069    /** Prefix for 10<sup>-2</sup>. */
070        MAHASHANKH("M", 10, 19);
071        
072    /**
073     * The symbol of this prefix, as returned by {@link #getSymbol}.
074     *
075     * @serial
076     * @see #getSymbol()
077     */
078    private final String symbol;
079
080    /**
081     * Base part of the associated factor in base^exponent representation.
082     */
083    private final int base;
084    
085    /**
086     * Exponent part of the associated factor in base^exponent representation.
087     */
088    private final int exponent;
089
090    /**
091     * Creates a new prefix.
092     *
093     * @param symbol
094     *          the symbol of this prefix.
095     * @param exponent
096     *          part of the associated factor in base^exponent representation.
097     */
098    private VedicPrefix(String symbol, int base, int exponent) {
099        this.symbol = symbol;
100        this.base = base;
101        this.exponent = exponent;
102    }
103    
104    /**
105     * Base part of the associated factor in {@code base^exponent} representation.
106     */
107    @Override
108    public Integer getValue() {
109        return base;
110    }
111    
112
113    /**
114     * Exponent part of the associated factor in base^exponent representation.
115     */
116    @Override
117    public int getExponent() {
118        return exponent;
119    }
120
121    /**
122     * Returns the name of this prefix.
123     *
124     * @return this prefix name, not {@code null}.
125     */
126    @Override
127    public String getName() {
128        return name();
129    }
130    
131    /**
132     * Returns the symbol of this prefix.
133     *
134     * @return this prefix symbol, not {@code null}.
135     */
136    @Override
137    public String getSymbol() {
138        return symbol;
139    }
140
141        /**
142         * <p>
143         * एक (Ek)
144         * </p>
145         * Returns the specified unit multiplied by the factor <code>1</code>
146         * 
147         * @param unit
148         *            any unit.
149         * @return <code>unit.times(1)</code>.
150         */
151        public static final <Q extends Quantity<Q>> Unit<Q> EK(Unit<Q> unit) {
152                return unit;
153        }
154
155        /**
156         * <p>
157         * दस (Das)
158         * </p>
159         * Returns the specified unit multiplied by the factor
160         * <code>10<sup>1</sup></code>
161         * 
162         * @param unit
163         *            any unit.
164         * @return <code>unit.times(10)</code>.
165         */
166        public static final <Q extends Quantity<Q>> Unit<Q> DAS(Unit<Q> unit) {
167                return unit.prefix(DAS);
168        }
169
170        /**
171         * <p>
172         * सौ (Sau)
173         * </p>
174         * Returns the specified unit multiplied by the factor
175         * <code>10<sup>2</sup></code>
176         * 
177         * @param unit
178         *            any unit.
179         * @return <code>unit.times(100)</code>.
180         */
181        public static final <Q extends Quantity<Q>> Unit<Q> SAU(Unit<Q> unit) {
182                return unit.prefix(SAU);
183        }
184
185        /**
186         * <p>
187         * सहस्र (Sahasr)
188         * </p>
189         * Returns the specified unit multiplied by the factor
190         * <code>10<sup>3</sup></code>
191         * 
192         * @param unit
193         *            any unit.
194         * @return <code>unit.times(1e3)</code>.
195         */
196        public static final <Q extends Quantity<Q>> Unit<Q> SAHASR(Unit<Q> unit) {
197                return unit.prefix(SAHASR);
198        }
199
200        /**
201         * <p>
202         * हजार (Hazaar)
203         * </p>
204         * Equivalent to {@link #SAHASR}.
205         */
206        public static final <Q extends Quantity<Q>> Unit<Q> HAZAAR(Unit<Q> unit) {
207                return SAHASR(unit);
208        }
209
210        /**
211         * <p>
212         * लाख (Lakh)
213         * </p>
214         * Returns the specified unit multiplied by the factor
215         * <code>10<sup>5</sup></code>
216         * 
217         * @param unit
218         *            any unit.
219         * @return <code>unit.times(1e5)</code>.
220         */
221        public static final <Q extends Quantity<Q>> Unit<Q> LAKH(Unit<Q> unit) {
222                return unit.prefix(LAKH);
223        }
224
225        /**
226         * <p>
227         * करोड़ (Crore)
228         * </p>
229         * Returns the specified unit multiplied by the factor
230         * <code>10<sup>7</sup></code>
231         * 
232         * @param unit
233         *            any unit.
234         * @return <code>unit.times(1e7)</code>.
235         */
236        public static final <Q extends Quantity<Q>> Unit<Q> CRORE(Unit<Q> unit) {
237                return unit.prefix(CRORE);
238        }
239
240        /**
241         * <p>
242         * अरब (Arawb)
243         * </p>
244         * Returns the specified unit multiplied by the factor
245         * <code>10<sup>9</sup></code>
246         * 
247         * @param unit
248         *            any unit.
249         * @return <code>unit.times(1e9)</code>.
250         */
251        public static final <Q extends Quantity<Q>> Unit<Q> ARAWB(Unit<Q> unit) {
252                return unit.prefix(ARAWB);
253        }
254
255        /**
256         * <p>
257         * खरब (Kharawb)
258         * </p>
259         * Returns the specified unit multiplied by the factor
260         * <code>10<sup>11</sup></code>
261         * 
262         * @param unit
263         *            any unit.
264         * @return <code>unit.times(1e11)</code>.
265         */
266        public static final <Q extends Quantity<Q>> Unit<Q> KHARAWB(Unit<Q> unit) {
267                return unit.prefix(KHARAWB);
268        }
269
270        /**
271         * <p>
272         * नील (Neel)
273         * </p>
274         * Returns the specified unit multiplied by the factor
275         * <code>10<sup>13</sup></code>
276         * 
277         * @param unit
278         *            any unit.
279         * @return <code>unit.times(1e13)</code>.
280         */
281        public static final <Q extends Quantity<Q>> Unit<Q> NEEL(Unit<Q> unit) {
282                return unit.prefix(NEEL);
283        }
284
285        /**
286         * <p>
287         * पद्म (Padma)
288         * </p>
289         * Returns the specified unit multiplied by the factor
290         * <code>10<sup>15</sup></code>
291         * 
292         * @param unit
293         *            any unit.
294         * @return <code>unit.times(1e15)</code>.
295         */
296        public static final <Q extends Quantity<Q>> Unit<Q> PADMA(Unit<Q> unit) {
297                return unit.prefix(PADMA);
298        }
299
300        /**
301         * <p>
302         * शंख (Shankh)
303         * </p>
304         * Returns the specified unit multiplied by the factor
305         * <code>10<sup>17</sup></code>
306         * 
307         * @param unit
308         *            any unit.
309         * @return <code>unit.times(1e17)</code>.
310         */
311        public static final <Q extends Quantity<Q>> Unit<Q> SHANKH(Unit<Q> unit) {
312                return unit.prefix(SHANKH);
313        }
314
315        /**
316         * <p>
317         * महाशंख (Mahashankh)
318         * </p>
319         * Returns the specified unit multiplied by the factor
320         * <code>10<sup>19</sup></code>
321         * 
322         * @param unit
323         *            any unit.
324         * @return <code>unit.times(1e19)</code>.
325         */
326        public static final <Q extends Quantity<Q>> Unit<Q> MAHASHANKH(Unit<Q> unit) {
327                return unit.prefix(MAHASHANKH);
328        }
329}