Skip to content

Commit

Permalink
Issue #14. Comment that empty string is ok
Browse files Browse the repository at this point in the history
  • Loading branch information
averbraeck committed Jul 24, 2023
1 parent a085680 commit e915c31
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/main/java/org/djunits/unit/Unit.java
Original file line number Diff line number Diff line change
Expand Up @@ -1048,7 +1048,8 @@ public String toString()
}

/**
* Find or create a unit for the given SI dimensions.
* Find or create a unit for the given SI dimensions. Note that unitString may be empty, corresponding to a Dimensionless
* unit.
* @param unitString String; the textual representation of the unit
* @return SIUnit; the unit
* @throws IllegalArgumentException when the unit cannot be parsed or is incorrect
Expand All @@ -1057,7 +1058,6 @@ public String toString()
public static SIUnit getUnit(final String unitString)
{
Throw.whenNull(unitString, "Error parsing SIVector: unitString is null");
Throw.when(unitString.length() == 0, IllegalArgumentException.class, "Error parsing SIVector: empty unitString");
try
{
SIUnit unit = Unit.lookupOrCreateUnitWithSIDimensions(SIDimensions.of(unitString));
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/djunits/unit/si/SIDimensions.java
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ public static SIDimensions of(final String siString) throws UnitException
* Translate a string representing SI dimensions to an SIDimensions object. Example: SIDimensions.of("kgm2") is translated
* to a vector {0,0,1,2,0,0,0,0,0}. It is allowed to use 0 or 1 for the dimensions. Dimensions between -9 and 9 are allowed.
* The parsing is quite lenient: periods and carets (^) are taken out, and the order can be arbitrary, so "kgms-2" is
* accepted as well as "m.s^-2.kg"
* accepted as well as "m.s^-2.kg". Note that the empty string parses to the dimensionless unit.
* @param siString String; concatenation of SI units with positive or negative dimensions. No divisions sign is allowed.
* @return byte[]; a vector of length <code>NUMBER_DIMENSIONS</code> with the dimensions for the SI units
* @throws UnitException when the String cannot be parsed, e.g. due to units not being recognized
Expand Down

0 comments on commit e915c31

Please sign in to comment.