001/* 002 * Units of Measurement API 003 * Copyright (c) 2014-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 javax.measure; 031 032import java.util.Map; 033 034/** 035 * Represents the dimension of a unit. 036 * 037 * <p>Concrete dimensions are obtained through the {@link Unit#getDimension()} method.</p> 038 * 039 * <p>Two units {@code u1} and {@code u2} are {@linkplain Unit#isCompatible(Unit) compatible} 040 * if and only if {@code u1.getDimension().equals(u2.getDimension())}.</p> 041 * 042 * @author <a href="mailto:jean-marie@dautelle.com">Jean-Marie Dautelle</a> 043 * @author <a href="mailto:units@catmedia.us">Werner Keil</a> 044 * @version 0.13, December 6, 2014 045 * 046 * @see <a href="http://en.wikipedia.org/wiki/Dimensional_analysis">Wikipedia: Dimensional Analysis</a> 047 */ 048public interface Dimension { 049 /** 050 * Returns the product of this dimension with the one specified. 051 * 052 * @param multiplicand the dimension multiplicand. 053 * @return {@code this * multiplicand} 054 */ 055 Dimension multiply(Dimension multiplicand); 056 057 /** 058 * Returns the quotient of this dimension with the one specified. 059 * 060 * @param divisor the dimension divisor. 061 * @return {@code this / divisor} 062 */ 063 Dimension divide(Dimension divisor); 064 065 /** 066 * Returns this dimension raised to an exponent. 067 * <tt>(this<sup>n</sup>)</tt> 068 * 069 * @param n power to raise this {@code Dimension} to. 070 * @return <tt>this<sup>n</sup></tt> 071 */ 072 Dimension pow(int n); 073 074 /** 075 * Returns the given root of this dimension. 076 * 077 * @param n the root's order. 078 * @return the result of taking the given root of this dimension. 079 * @throws ArithmeticException if {@code n == 0}. 080 */ 081 Dimension root(int n); 082 083 /** 084 * Returns the fundamental dimensions and their exponent whose product is 085 * this dimension, or {@code null} if this dimension is a fundamental dimension. 086 * 087 * @return the mapping between the fundamental dimensions and their exponent. 088 */ 089 Map<? extends Dimension, Integer> getProductDimensions(); 090}