All Downloads are FREE. Search and download functionalities are using the official Maven repository.

ucar.units.UnitSymbol Maven / Gradle / Ivy

The newest version!
/*
 * Copyright (c) 1998-2018 University Corporation for Atmospheric Research/Unidata
 * See LICENSE for license information.
 */
package ucar.units;

/**
 * Provides support for symbols for units.
 * 
 * @author Steven R. Emmerson
 */
public final class UnitSymbol extends UnitID {
  private static final long serialVersionUID = 1L;
  /**
   * The symbol for the unit.
   * 
   * @serial
   */
  private final String symbol;

  /**
   * Constructs from a symbol.
   * 
   * @param symbol
   *        The symbol for the unit. Shall not be 
   *        null.
   */
  public UnitSymbol(final String symbol) throws NameException {
    if (symbol == null) {
      throw new NameException("Symbol can't be null");
    }
    this.symbol = symbol;
  }

  /**
   * Returns the name of the unit. Always returns null.
   * 
   * @return null.
   */
  @Override
  public String getName() {
    return null;
  }

  /**
   * Returns the plural form of the name of the unit. Always returns
   * null.
   * 
   * @return null.
   */
  @Override
  public String getPlural() {
    return null;
  }

  /**
   * Returns the symbol for the unit.
   * 
   * @return The symbol for the unit. Never null
   *        .
   */
  @Override
  public String getSymbol() {
    return symbol;
  }

  /**
   * Returns the string representation of this identifier.
   * 
   * @return The string representation of this identifier.
   */
  @Override
  public String toString() {
    return getSymbol();
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy