Tabnine Logo
Unit.getSystemUnit
Code IndexAdd Tabnine to your IDE (free)

How to use
getSystemUnit
method
in
javax.measure.Unit

Best Java code snippets using javax.measure.Unit.getSystemUnit (Showing top 20 results out of 315)

origin: geotools/geotools

@Override
public int hashCode() {
  if (unit instanceof TransformedUnit<?>) {
    Unit<?> systemUnit = unit.getSystemUnit();
    try {
      float factor1 = (float) unit.getConverterToAny(systemUnit).convert(1.0);
      return Objects.hash(systemUnit, Float.floatToIntBits(factor1));
    } catch (UnconvertibleException | IncommensurableException e) {
    } catch (Throwable e) {
    }
  }
  return unit.hashCode();
}
origin: eclipse/smarthome

@Override
public int compareTo(QuantityType<T> o) {
  if (quantity.getUnit().isCompatible(o.quantity.getUnit())) {
    QuantityType<T> v1 = this.toUnit(getUnit().getSystemUnit());
    QuantityType<?> v2 = o.toUnit(o.getUnit().getSystemUnit());
    if (v1 != null && v2 != null) {
      return Double.compare(v1.doubleValue(), v2.doubleValue());
    } else {
      throw new IllegalArgumentException("Unable to convert to system unit during compare.");
    }
  } else {
    throw new IllegalArgumentException("Can not compare incompatible units.");
  }
}
origin: geotools/geotools

TransformedUnit<?> tunit1 = (TransformedUnit<?>) unit1;
TransformedUnit<?> tunit2 = (TransformedUnit<?>) unit2;
if (unit1.getSystemUnit().equals(unit2.getSystemUnit())) {
  try {
    float factor =
origin: geotools/geotools

public static final boolean isUSSurveyFoot(Unit<?> unit) {
  if (unit == null) {
    return false;
  } else if (USCustomary.FOOT_SURVEY.equals(unit)) {
    return true;
  } else if (unit.getSystemUnit() == SI.METRE && unit instanceof TransformedUnit<?>) {
    @SuppressWarnings("unchecked")
    TransformedUnit<Length> transformed = (TransformedUnit<Length>) unit;
    UnitConverter converter = transformed.getConverter();
    if (converter instanceof MultiplyConverter) {
      MultiplyConverter multiplyConverter = (MultiplyConverter) converter;
      double factor = multiplyConverter.getFactor();
      // 0.3048006096012192  // observed
      // 0.3048006096        // expected
      if (Math.abs(US_SURVEY_FOOT_FACTORY - factor) < US_SURVEY_FOOT_COMPARISON_EPSILON) {
        return true;
      }
    }
  }
  return false;
}
origin: geotools/geotools

  /**
   * Recognize representation of NonSI.DEEGREE_ANGLE to prevent unnecessary conversion.
   *
   * @param unit
   * @return true if MultiplyConverter is close to PI/180.0
   */
  public static final boolean isDegreeAngle(Unit<?> unit) {
    if (unit == null) {
      return false;
    } else if (NonSI.DEGREE_ANGLE.equals(unit)) {
      return true;
    }
    if (unit.getSystemUnit() == SI.RADIAN && unit instanceof TransformedUnit<?>) {
      @SuppressWarnings("unchecked")
      TransformedUnit<Angle> transformed = (TransformedUnit<Angle>) unit;
      UnitConverter converter = transformed.getConverter();
      if (converter instanceof MultiplyConverter) {
        MultiplyConverter multiplyConverter = (MultiplyConverter) converter;
        double factor = multiplyConverter.getFactor();
        if (Math.abs(RADIAN_TO_DEGREE_RATIO - factor) < DEEGREE_RATIO_COMPARISON_EPSILON) {
          return true;
        }
      }
    }
    return false;
  }
}
origin: eclipse/smarthome

Unit<?> itemUnit = getUnit();
Unit<?> stateUnit = ((QuantityType<?>) state).getUnit();
if (itemUnit != null && (!stateUnit.getSystemUnit().equals(itemUnit.getSystemUnit())
    || UnitUtils.isDifferentMeasurementSystem(itemUnit, stateUnit))) {
  QuantityType<?> convertedState = ((QuantityType<?>) state).toUnit(itemUnit);
origin: tec.units/indriya

/**
 * Creates a transformed unit from the specified parent unit.
 *
 * @param symbol
 *          the symbol to use with this transformed unit.
 * @param parentUnit
 *          the parent unit from which this unit is derived.
 * @param unitConverter
 *          the converter to the parent units.
 */
public TransformedUnit(String symbol, Unit<Q> parentUnit, UnitConverter unitConverter) {
 this(symbol, parentUnit, parentUnit.getSystemUnit(), unitConverter);
}
origin: tec.units/unit-ri

@Override
public AbstractUnit<Q> toSystemUnit() {
 return (AbstractUnit<Q>) actualUnit.getSystemUnit();
}
origin: org.apache.sis.core/sis-utility

/**
 * Returns {@code true} if the given unit is a pressure unit.
 * Pressure units are convertible to {@link #PASCAL}.
 * Those units are sometime used instead of linear units for altitude measurements.
 *
 * @param  unit  the unit to check (may be {@code null}).
 * @return {@code true} if the given unit is non-null and a pressure unit.
 */
public static boolean isPressure(final Unit<?> unit) {
  return (unit != null) && unit.getSystemUnit().equals(PASCAL);
}
origin: org.apache.sis.core/sis-utility

/**
 * Returns {@code true} if the given unit is a temporal unit.
 * Temporal units are convertible to {@link #SECOND}.
 *
 * @param  unit  the unit to check (may be {@code null}).
 * @return {@code true} if the given unit is non-null and temporal.
 *
 * @see #ensureTemporal(Unit)
 */
public static boolean isTemporal(final Unit<?> unit) {
  return (unit != null) && unit.getSystemUnit().equals(SECOND);
}
origin: apache/sis

/**
 * Returns {@code true} if the given unit is a pressure unit.
 * Pressure units are convertible to {@link #PASCAL}.
 * Those units are sometime used instead of linear units for altitude measurements.
 *
 * @param  unit  the unit to check (may be {@code null}).
 * @return {@code true} if the given unit is non-null and a pressure unit.
 */
public static boolean isPressure(final Unit<?> unit) {
  return (unit != null) && unit.getSystemUnit().equals(PASCAL);
}
origin: apache/sis

/**
 * Returns {@code true} if the given unit is a temporal unit.
 * Temporal units are convertible to {@link #SECOND}.
 *
 * @param  unit  the unit to check (may be {@code null}).
 * @return {@code true} if the given unit is non-null and temporal.
 *
 * @see #ensureTemporal(Unit)
 */
public static boolean isTemporal(final Unit<?> unit) {
  return (unit != null) && unit.getSystemUnit().equals(SECOND);
}
origin: org.apache.sis.core/sis-utility

/**
 * Returns {@code true} if the given unit is a dimensionless scale unit.
 * This include {@link #UNITY} and {@link #PPM}.
 *
 * @param  unit  the unit to check (may be {@code null}).
 * @return {@code true} if the given unit is non-null and a dimensionless scale.
 *
 * @see #UNITY
 * @see #ensureScale(Unit)
 */
public static boolean isScale(final Unit<?> unit) {
  return (unit != null) && unit.getSystemUnit().equals(UNITY);
}
origin: tec.units/indriya

/**
 * Convenient method equivalent to {@link #to(javax.measure.unit.Unit) to(this.getUnit().toSI())}.
 *
 * @return this measure or a new measure equivalent to this measure but stated in SI units.
 * @throws ArithmeticException
 *           if the result is inexact and the quotient has a non-terminating decimal expansion.
 */
public Quantity<Q> toSI() {
 return to(this.getUnit().getSystemUnit());
}
origin: tec.units/unit-ri

/**
 * Convenient method equivalent to {@link #to(javax.measure.unit.Unit) to(this.getUnit().toSI())}.
 *
 * @return this measure or a new measure equivalent to this measure but stated in SI units.
 * @throws ArithmeticException
 *           if the result is inexact and the quotient has a non-terminating decimal expansion.
 */
public Quantity<Q> toSI() {
 return to(this.getUnit().getSystemUnit());
}
origin: tec.uom/uom-se

/**
 * Convenient method equivalent to {@link #to(javax.measure.unit.Unit) to(this.getUnit().toSI())}.
 *
 * @return this measure or a new measure equivalent to this measure but stated in SI units.
 * @throws ArithmeticException
 *           if the result is inexact and the quotient has a non-terminating decimal expansion.
 */
public Quantity<Q> toSI() {
 return to(this.getUnit().getSystemUnit());
}
origin: tec.units/indriya

@SuppressWarnings("unchecked")
@Override
public Unit<Q> toSystemUnit() {
 Unit<?> systemUnit = AbstractUnit.ONE;
 for (Element element : elements) {
  Unit<?> unit = element.unit.getSystemUnit();
  unit = unit.pow(element.pow);
  unit = unit.root(element.root);
  systemUnit = systemUnit.multiply(unit);
 }
 return (AbstractUnit<Q>) systemUnit;
}
origin: tec.units/unit-ri

@SuppressWarnings("unchecked")
@Override
public AbstractUnit<Q> toSystemUnit() {
 Unit<?> systemUnit = AbstractUnit.ONE;
 for (Element element : elements) {
  Unit<?> unit = element.unit.getSystemUnit();
  unit = unit.pow(element.pow);
  unit = unit.root(element.root);
  systemUnit = systemUnit.multiply(unit);
 }
 return (AbstractUnit<Q>) systemUnit;
}
origin: tec.uom/uom-se

@SuppressWarnings("unchecked")
@Override
public AbstractUnit<Q> toSystemUnit() {
 Unit<?> systemUnit = AbstractUnit.ONE;
 for (Element element : elements) {
  Unit<?> unit = element.unit.getSystemUnit();
  unit = unit.pow(element.pow);
  unit = unit.root(element.root);
  systemUnit = systemUnit.multiply(unit);
 }
 return (AbstractUnit<Q>) systemUnit;
}
origin: apache/sis

  /**
   * Returns the converter to standard unit.
   */
  private static <Q extends Quantity<Q>> UnitConverter toStandardUnit(final Unit<Q> unit) {
    return unit.getConverterTo(unit.getSystemUnit());
  }
}
javax.measureUnitgetSystemUnit

Popular methods of Unit

  • getConverterTo
  • toString
  • multiply
  • getConverterToAny
  • asType
  • isCompatible
  • divide
  • getSymbol
  • getDimension
  • transform
  • getName
  • pow
  • getName,
  • pow,
  • root,
  • shift,
  • getBaseUnits,
  • inverse,
  • alternate

Popular in Java

  • Reading from database using SQL prepared statement
  • startActivity (Activity)
  • setRequestProperty (URLConnection)
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • Rectangle (java.awt)
    A Rectangle specifies an area in a coordinate space that is enclosed by the Rectangle object's top-
  • MessageDigest (java.security)
    Uses a one-way hash function to turn an arbitrary number of bytes into a fixed-length byte sequence.
  • NumberFormat (java.text)
    The abstract base class for all number formats. This class provides the interface for formatting and
  • Comparator (java.util)
    A Comparator is used to compare two objects to determine their ordering with respect to each other.
  • SortedMap (java.util)
    A map that has its keys ordered. The sorting is according to either the natural ordering of its keys
  • ExecutorService (java.util.concurrent)
    An Executor that provides methods to manage termination and methods that can produce a Future for tr
  • Top PhpStorm plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now