001/*
002 * Units of Measurement Enum Implementation
003 * Copyright © 2005-2021, 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, Unit-API nor the names of their 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 tech.uom.impl.enums.quantity;
031
032import javax.measure.Quantity;
033import javax.measure.Unit;
034import javax.measure.quantity.Area;
035import javax.measure.quantity.Dimensionless;
036
037import tech.uom.impl.enums.AbstractQuantity;
038import tech.uom.impl.enums.format.UnitStyle;
039import tech.uom.impl.enums.unit.DimensionlessUnit;
040
041/**
042 * @author Werner Keil
043 * @version 0.7
044 */
045public class DimensionlessQuantity extends AbstractQuantity<Dimensionless> implements Dimensionless {
046        private final double scalar;
047        private final Double value; // value in unit (Unit unit)
048
049        private final Unit unit;
050
051        
052        public DimensionlessQuantity(double val, Unit un) {
053                value = val;
054                unit = un;
055                scalar = 1;
056        }
057
058        public DimensionlessQuantity(Number val, Unit un) {
059                this(val.doubleValue(), un);
060        }
061        
062        public DimensionlessQuantity multiply(double v) {
063                return new DimensionlessQuantity(value * v, (DimensionlessUnit) unit);
064        }
065
066        public DimensionlessQuantity divide(double v) {
067                return new DimensionlessQuantity(value / v, (DimensionlessUnit) unit);
068        }
069
070        public DimensionlessQuantity convert(DimensionlessUnit newUnit) {
071                return new DimensionlessQuantity(scalar, newUnit);
072        }
073
074        public Quantity<?> divide(Quantity<?> that) {
075                // TODO Auto-generated method stub
076                return null;
077        }
078
079        public Quantity<Dimensionless> to(Unit<Dimensionless> unit) {
080                // TODO Auto-generated method stub
081                return null;
082        }
083
084        public Quantity<Dimensionless> subtract(Quantity<Dimensionless> that) {
085                // TODO Auto-generated method stub
086                return null;
087        }
088
089        public Quantity<Dimensionless> add(Quantity<Dimensionless> that) {
090                // TODO Auto-generated method stub
091                return null;
092        }
093
094        public Quantity<Dimensionless> divide(Number that) {
095                // TODO Auto-generated method stub
096                return null;
097        }
098
099        public Quantity<Dimensionless> inverse() {
100                // TODO Auto-generated method stub
101                return null;
102        }
103
104        public Quantity<Dimensionless> multiply(Number that) {
105                // TODO Auto-generated method stub
106                return null;
107        }
108
109        public Quantity<?> multiply(Quantity<?> that) {
110                // TODO Auto-generated method stub
111                return null;
112        }
113
114        public Area multiply(Dimensionless l) {
115                // TODO Auto-generated method stub
116                return null;
117        }
118
119        @Override
120        public Number getValue() {
121                return value;
122        }
123
124        @SuppressWarnings("unchecked")
125        @Override
126        public Unit<Dimensionless> getUnit() {
127                return unit;
128        }
129
130        @Override
131        public int compareTo(Quantity<Dimensionless> o) {
132                // TODO Auto-generated method stub
133                return 0;
134        }
135
136        @Override
137        protected Number getScalar() {
138                // TODO Auto-generated method stub
139                return null;
140        }
141
142        @Override
143        protected boolean eq(AbstractQuantity<Dimensionless> dq) {
144                // TODO Auto-generated method stub
145                return false;
146        }
147
148        @Override
149        protected boolean isZero() {
150                // TODO Auto-generated method stub
151                return false;
152        }
153
154        @Override
155        public String toString(boolean withUnit, boolean withSpace, int precision) {
156                // TODO Auto-generated method stub
157                return null;
158        }
159
160        @Override
161        protected String showInUnit(Unit<?> u, int precision, UnitStyle style) {
162                // TODO Auto-generated method stub
163                return null;
164        }
165
166        @Override
167        public Quantity<Dimensionless> negate() {
168                return new DimensionlessQuantity(-value.doubleValue(), unit);
169        }
170}