/** * Gets the name of the unit. * * @return The name of the unit. May be <code>null</code>. */ public final String getName() { return id == null ? null : id.getName(); }
/** * Factory method for constructing a UnitName from a name, a plural form of * the name, and a symbol. * * @param name * The name of the unit. Shall not be <code> * null</code>. * @param plural * The plural form of the name. May be <code> * null</code>, in which * case regular plural- forming rules are used to construct the * plural form from the name. * @param symbol * The symbol for the unit. May be <code>null * </code>. * @throws NameException * <code>name == null</code>. */ public static UnitName newUnitName(final String name, final String plural, final String symbol) throws NameException { return new UnitName(name, plural, symbol); }
/** * Indicates if this UnitName is semantically identical to an object. */ @Override public final boolean equals(final Object object) { return object instanceof UnitName && compareTo(object) == 0; }
/** * Constructs from a name. * * @param name The name of the unit. */ private UnknownUnit(final String name) throws NameException { super(UnitName.newUnitName(name, null, name), BaseQuantity.UNKNOWN); }
/** * Gets the symbol for the unit. * * @return The symbol of the unit. May be <code>null</code>. */ public final String getSymbol() { return id == null ? null : id.getSymbol(); }
/** * Gets the plural form of the name of the unit. * * @return The plural of the name of the unit. May be <code>null</code>. */ public final String getPlural() { return id == null ? null : id.getPlural(); }
/** * Constructs from a name, a plural form of the unit name, and a symbol. * * @param name * The name of the unit. Shall not be <code> * null</code>. * @param plural * The plural form of the name. May be <code> * null</code>, in which * case regular plural- forming rules are used to construct the * plural form from the name. * @param symbol * The symbol for the unit. May be <code>null * </code>. * @throws NameException * <code>name == null</code>. */ protected UnitName(final String name, final String plural, final String symbol) throws NameException { if (name == null) { throw new NameException("Unit name can't be null"); } this.name = name; this.plural = plural == null ? makePlural(name) : plural; this.symbol = symbol; }
if ((nameUnit != null && !baseQuantity.equals(nameUnit .getBaseQuantity())) || (quantityUnit != null && !id.equals(quantityUnit .getUnitName()))) { throw new UnitExistsException(
/** * Factory method for constructing a UnitName from a name. * * @param name * The name of the unit. Shall not be <code> * null</code>. * @throws NameException * <code>name == null</code>. */ public static UnitName newUnitName(final String name) throws NameException { return newUnitName(name, null); }
/** * Gets the symbol for the unit. * * @return The symbol of the unit. May be <code>null</code>. */ public final String getSymbol() { return id == null ? null : id.getSymbol(); }
/** * Gets the plural form of the name of the unit. * * @return The plural of the name of the unit. May be <code>null</code>. */ public final String getPlural() { return id == null ? null : id.getPlural(); }
/** * Constructs from a name, a plural form of the unit name, and a symbol. * * @param name * The name of the unit. Shall not be <code> * null</code>. * @param plural * The plural form of the name. May be <code> * null</code>, in which * case regular plural- forming rules are used to construct the * plural form from the name. * @param symbol * The symbol for the unit. May be <code>null * </code>. * @throws NameException * <code>name == null</code>. */ protected UnitName(final String name, final String plural, final String symbol) throws NameException { if (name == null) { throw new NameException("Unit name can't be null"); } this.name = name; this.plural = plural == null ? makePlural(name) : plural; this.symbol = symbol; }
if ((nameUnit != null && !baseQuantity.equals(nameUnit .getBaseQuantity())) || (quantityUnit != null && !id.equals(quantityUnit .getUnitName()))) { throw new UnitExistsException(
/** * Factory method for constructing a UnitName from a name. * * @param name * The name of the unit. Shall not be <code> * null</code>. * @throws NameException * <code>name == null</code>. */ public static UnitName newUnitName(final String name) throws NameException { return newUnitName(name, null); }
/** * Gets the name of the unit. * * @return The name of the unit. May be <code>null</code>. */ public final String getName() { return id == null ? null : id.getName(); }
/** * Constructs from identifiers and a base quantity. * * @param id * The identifiers for the base unit. <code> * id.getSymbol()</code> * shall not return <code> * null</code>. * @param baseQuantity * The base quantity of the base unit. * @throws NameException * <code>id.getSymbol()</code> returned <code> * null</code>. */ protected BaseUnit(final UnitName id, final BaseQuantity baseQuantity) throws NameException { super(id); if (id.getSymbol() == null) { throw new NameException("Base unit must have symbol"); } setDimension(new UnitDimension(this)); this.baseQuantity = baseQuantity; }
/** * Indicates if this UnitName is semantically identical to an object. */ @Override public final boolean equals(final Object object) { return object instanceof UnitName && compareTo(object) == 0; }
/** * Factory method for constructing a UnitName from a name, a plural form of * the name, and a symbol. * * @param name * The name of the unit. Shall not be <code> * null</code>. * @param plural * The plural form of the name. May be <code> * null</code>, in which * case regular plural- forming rules are used to construct the * plural form from the name. * @param symbol * The symbol for the unit. May be <code>null * </code>. * @throws NameException * <code>name == null</code>. */ public static UnitName newUnitName(final String name, final String plural, final String symbol) throws NameException { return new UnitName(name, plural, symbol); }