|
1 |
| -/* |
2 |
| - * Units of Measurement API |
3 |
| - * Copyright (c) 2014-2018, Jean-Marie Dautelle, Werner Keil, Otavio Santana. |
4 |
| - * |
5 |
| - * All rights reserved. |
6 |
| - * |
7 |
| - * Redistribution and use in source and binary forms, with or without modification, |
8 |
| - * are permitted provided that the following conditions are met: |
9 |
| - * |
10 |
| - * 1. Redistributions of source code must retain the above copyright notice, |
11 |
| - * this list of conditions and the following disclaimer. |
12 |
| - * |
13 |
| - * 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions |
14 |
| - * and the following disclaimer in the documentation and/or other materials provided with the distribution. |
15 |
| - * |
16 |
| - * 3. Neither the name of JSR-385 nor the names of its contributors may be used to endorse or promote products |
17 |
| - * derived from this software without specific prior written permission. |
18 |
| - * |
19 |
| - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
20 |
| - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, |
21 |
| - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
22 |
| - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
23 |
| - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
24 |
| - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
25 |
| - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED |
26 |
| - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 |
| - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, |
28 |
| - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 |
| - */ |
30 |
| -package javax.measure; |
31 |
| - |
32 |
| -import java.util.Map; |
33 |
| - |
34 |
| -/** |
35 |
| - * Represents the dimension of a unit. |
36 |
| - * |
37 |
| - * <p> |
38 |
| - * Concrete dimensions are obtained through the {@link Unit#getDimension()} method. |
39 |
| - * </p> |
40 |
| - * |
41 |
| - * <p> |
42 |
| - * Two units {@code u1} and {@code u2} are {@linkplain Unit#isCompatible(Unit) compatible} if and only if |
43 |
| - * {@code u1.getDimension().equals(u2.getDimension())}. |
44 |
| - * </p> |
45 |
| - * |
46 |
| - * @author <a href="mailto:[email protected]">Jean-Marie Dautelle</a> |
47 |
| - * @author <a href="mailto:[email protected]">Werner Keil</a> |
48 |
| - * @version 1.0, August 8, 2016 |
49 |
| - * @since 1.0 |
50 |
| - * @see Unit |
51 |
| - * @see <a href="http://en.wikipedia.org/wiki/Dimensional_analysis">Wikipedia: Dimensional Analysis</a> |
52 |
| - */ |
53 |
| -public interface Dimension { |
54 |
| - /** |
55 |
| - * Returns the product of this dimension with the one specified. |
56 |
| - * |
57 |
| - * @param multiplicand |
58 |
| - * the dimension multiplicand. |
59 |
| - * @return {@code this * multiplicand} |
60 |
| - */ |
61 |
| - Dimension multiply(Dimension multiplicand); |
62 |
| - |
63 |
| - /** |
64 |
| - * Returns the quotient of this dimension with the one specified. |
65 |
| - * |
66 |
| - * @param divisor |
67 |
| - * the dimension divisor. |
68 |
| - * @return {@code this / divisor} |
69 |
| - */ |
70 |
| - Dimension divide(Dimension divisor); |
71 |
| - |
72 |
| - /** |
73 |
| - * Returns this dimension raised to an exponent. <tt>(this<sup>n</sup>)</tt> |
74 |
| - * |
75 |
| - * @param n |
76 |
| - * power to raise this {@code Dimension} to. |
77 |
| - * @return <tt>this<sup>n</sup></tt> |
78 |
| - */ |
79 |
| - Dimension pow(int n); |
80 |
| - |
81 |
| - /** |
82 |
| - * Returns the given root of this dimension. |
83 |
| - * |
84 |
| - * @param n |
85 |
| - * the root's order. |
86 |
| - * @return the result of taking the given root of this dimension. |
87 |
| - * @throws ArithmeticException |
88 |
| - * if {@code n == 0}. |
89 |
| - */ |
90 |
| - Dimension root(int n); |
91 |
| - |
92 |
| - /** |
93 |
| - * Returns the (fundamental) base dimensions and their exponent whose product is this dimension, or {@code null} if this dimension is a base |
94 |
| - * dimension. |
95 |
| - * |
96 |
| - * @return the mapping between the fundamental dimensions and their exponent. |
97 |
| - */ |
98 |
| - Map<? extends Dimension, Integer> getBaseDimensions(); |
99 |
| -} |
| 1 | +/* |
| 2 | + * Units of Measurement API |
| 3 | + * Copyright (c) 2014-2018, Jean-Marie Dautelle, Werner Keil, Otavio Santana. |
| 4 | + * |
| 5 | + * All rights reserved. |
| 6 | + * |
| 7 | + * Redistribution and use in source and binary forms, with or without modification, |
| 8 | + * are permitted provided that the following conditions are met: |
| 9 | + * |
| 10 | + * 1. Redistributions of source code must retain the above copyright notice, |
| 11 | + * this list of conditions and the following disclaimer. |
| 12 | + * |
| 13 | + * 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions |
| 14 | + * and the following disclaimer in the documentation and/or other materials provided with the distribution. |
| 15 | + * |
| 16 | + * 3. Neither the name of JSR-385 nor the names of its contributors may be used to endorse or promote products |
| 17 | + * derived from this software without specific prior written permission. |
| 18 | + * |
| 19 | + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| 20 | + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, |
| 21 | + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 22 | + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
| 23 | + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| 24 | + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| 25 | + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED |
| 26 | + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 | + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, |
| 28 | + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 | + */ |
| 30 | +package javax.measure; |
| 31 | + |
| 32 | +import java.util.Map; |
| 33 | + |
| 34 | +/** |
| 35 | + * Represents the dimension of a unit. |
| 36 | + * |
| 37 | + * <p> |
| 38 | + * Concrete dimensions are obtained through the {@link Unit#getDimension()} method. |
| 39 | + * </p> |
| 40 | + * |
| 41 | + * <p> |
| 42 | + * Two units {@code u1} and {@code u2} are {@linkplain Unit#isCompatible(Unit) compatible} if and only if |
| 43 | + * {@code u1.getDimension().equals(u2.getDimension())}. |
| 44 | + * </p> |
| 45 | + * |
| 46 | + * @author <a href="mailto:[email protected]">Jean-Marie Dautelle</a> |
| 47 | + * @author <a href="mailto:[email protected]">Werner Keil</a> |
| 48 | + * @version 1.0, August 8, 2016 |
| 49 | + * @since 1.0 |
| 50 | + * @see Unit |
| 51 | + * @see <a href="http://en.wikipedia.org/wiki/Dimensional_analysis">Wikipedia: Dimensional Analysis</a> |
| 52 | + */ |
| 53 | +public interface Dimension { |
| 54 | + /** |
| 55 | + * Returns the product of this dimension with the one specified. |
| 56 | + * |
| 57 | + * @param multiplicand |
| 58 | + * the dimension multiplicand. |
| 59 | + * @return {@code this * multiplicand} |
| 60 | + */ |
| 61 | + Dimension multiply(Dimension multiplicand); |
| 62 | + |
| 63 | + /** |
| 64 | + * Returns the quotient of this dimension with the one specified. |
| 65 | + * |
| 66 | + * @param divisor |
| 67 | + * the dimension divisor. |
| 68 | + * @return {@code this / divisor} |
| 69 | + */ |
| 70 | + Dimension divide(Dimension divisor); |
| 71 | + |
| 72 | + /** |
| 73 | + * Returns this dimension raised to an exponent. <tt>(this<sup>n</sup>)</tt> |
| 74 | + * |
| 75 | + * @param n |
| 76 | + * power to raise this {@code Dimension} to. |
| 77 | + * @return <tt>this<sup>n</sup></tt> |
| 78 | + */ |
| 79 | + Dimension pow(int n); |
| 80 | + |
| 81 | + /** |
| 82 | + * Returns the given root of this dimension. |
| 83 | + * |
| 84 | + * @param n |
| 85 | + * the root's order. |
| 86 | + * @return the result of taking the given root of this dimension. |
| 87 | + * @throws ArithmeticException |
| 88 | + * if {@code n == 0}. |
| 89 | + */ |
| 90 | + Dimension root(int n); |
| 91 | + |
| 92 | + /** |
| 93 | + * Returns the (fundamental) base dimensions and their exponent whose product is this dimension, or {@code null} if this dimension is a base |
| 94 | + * dimension. |
| 95 | + * |
| 96 | + * @return the mapping between the fundamental dimensions and their exponent. |
| 97 | + */ |
| 98 | + Map<? extends Dimension, Integer> getBaseDimensions(); |
| 99 | +} |
0 commit comments