View Javadoc
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-01-18 00:35:01 +0100 (Fri, 18 Jan 2019) $, @version $Revision: 324 $, 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", "DimensionlessUnit.si", OTHER);
28      }
29  
30      /**
31       * @param nameKey String; the key to the locale file for the long name of the unit
32       * @param abbreviationKey String; the key to the locale file for the abbreviation of the unit
33       * @param unitSystem UnitSystem; the unit system, e.g. SI or Imperial
34       */
35      private DimensionlessUnit(final String nameKey, final String abbreviationKey, final UnitSystem unitSystem)
36      {
37          super(nameKey, abbreviationKey, unitSystem, true);
38      }
39  
40      /** {@inheritDoc} */
41      @Override
42      public DimensionlessUnit getStandardUnit()
43      {
44          return SI;
45      }
46  
47      /** {@inheritDoc} */
48      @Override
49      public String getSICoefficientsString()
50      {
51          return "1";
52      }
53  
54      /** {@inheritDoc} */
55      @SuppressWarnings("checkstyle:needbraces")
56      @Override
57      public boolean equalsIgnoreNaming(final Object obj)
58      {
59          // Two DimensionlessUnit instances are always the same numerically, as they are unscaled.
60          if (this == obj)
61              return true;
62          if (getClass() != obj.getClass())
63              return false;
64          return true;
65      }
66  }