1 package org.djunits.unit;
2
3 import static org.djunits.unit.unitsystem.UnitSystem.OTHER;
4
5 import org.djunits.unit.unitsystem.UnitSystem;
6
7 /**
8 * Dimensionless unit.
9 * <p>
10 * Copyright (c) 2015-2019 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
11 * BSD-style license. See <a href="http://djunits.org/docs/license.html">DJUNITS License</a>.
12 * <p>
13 * $LastChangedDate: 2019-03-02 19:06:46 +0100 (Sat, 02 Mar 2019) $, @version $Revision: 342 $, by $Author: averbraeck $,
14 * initial version Jun 5, 2014 <br>
15 * @author <a href="http://www.tbm.tudelft.nl/averbraeck">Alexander Verbraeck</a>
16 */
17 public final class DimensionlessUnit extends Unit<DimensionlessUnit>
18 {
19 /** */
20 private static final long serialVersionUID = 20150830L;
21
22 /** The SI unit for a dimensionless unit is "1" or N/A. */
23 public static final DimensionlessUnit SI;
24
25 static
26 {
27 SI = new DimensionlessUnit("DimensionlessUnit.si", OTHER);
28 }
29
30 /**
31 * @param abbreviationKey String; the key to the locale file for the abbreviation of the unit
32 * @param unitSystem UnitSystem; the unit system, e.g. SI or Imperial
33 */
34 private DimensionlessUnit(final String abbreviationKey, final UnitSystem unitSystem)
35 {
36 super(abbreviationKey, unitSystem);
37 }
38
39 /** {@inheritDoc} */
40 @Override
41 public DimensionlessUnit getStandardUnit()
42 {
43 return SI;
44 }
45
46 /** {@inheritDoc} */
47 @Override
48 public String getSICoefficientsString()
49 {
50 return "1";
51 }
52
53 /** {@inheritDoc} */
54 @SuppressWarnings("checkstyle:needbraces")
55 @Override
56 public boolean equalsIgnoreNaming(final Object obj)
57 {
58 // Two DimensionlessUnit instances are always the same numerically, as they are unscaled.
59 if (this == obj)
60 return true;
61 if (getClass() != obj.getClass())
62 return false;
63 return true;
64 }
65 }