1 package org.djunits.unit; 2 3 import org.djunits.unit.unitsystem.UnitSystem; 4 5 /** 6 * Helper class to create arbitrary SI units. 7 * <p> 8 * Copyright (c) 2015-2019 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br> 9 * BSD-style license. See <a href="http://djunits.org/docs/license.html">DJUNITS License</a>. 10 * <p> 11 * $LastChangedDate: 2019-03-02 19:06:46 +0100 (Sat, 02 Mar 2019) $, @version $Revision: 342 $, by $Author: averbraeck $, 12 * initial version Jun 15, 2014 <br> 13 * @author <a href="http://www.tbm.tudelft.nl/averbraeck">Alexander Verbraeck</a> 14 */ 15 public class SIUnit extends Unit<SIUnit> 16 { 17 /** */ 18 private static final long serialVersionUID = 20140615L; 19 20 /** 21 * Create an arbitrary SI unit based on a coefficient string, such as m3/cd2. 22 * @param siCoefficientString String; textual description of the unit. 23 */ 24 public SIUnit(final String siCoefficientString) 25 { 26 super(siCoefficientString, siCoefficientString, UnitSystem.SI_DERIVED); 27 } 28 29 /** {@inheritDoc} */ 30 @Override 31 public final SIUnit getStandardUnit() 32 { 33 return this; 34 } 35 36 /** {@inheritDoc} */ 37 @Override 38 public final String getSICoefficientsString() 39 { 40 if (null == this.getAbbreviationKey()) 41 { 42 return this.getAbbreviation().replace("SIUnit.", ""); // FIXME: this is horrible / PK 43 // We need a better way to determine if a unit is supposed to have localization information. 44 } 45 return this.getAbbreviationKey().replace("SIUnit.", ""); 46 } 47 48 /** {@inheritDoc} */ 49 @SuppressWarnings("checkstyle:needbraces") 50 @Override 51 public boolean equalsIgnoreNaming(final Object obj) 52 { 53 // naming is done with a normalized SI-String, which should be equal when te SI units are equal. 54 // Therefore, we can call the equals() method that compares class, name and abbreviation. 55 return equals(obj); 56 } 57 58 }