Codota Logo
Unit.getSystemUnit
Code IndexAdd Codota 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)

  • Common ways to obtain Unit
private void myMethod () {
Unit u =
  • Codota IconQuantity quantity;quantity.getUnit()
  • Codota IconParameterDescriptor descriptor;descriptor.getUnit()
  • Codota IconCharSequence charSequence;SimpleUnitFormat.getInstance().parse(charSequence)
  • Smart code suggestions by Codota
}
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 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: 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

  • Updating database using SQL prepared statement
  • getSupportFragmentManager (FragmentActivity)
  • requestLocationUpdates (LocationManager)
  • getSharedPreferences (Context)
  • ObjectMapper (com.fasterxml.jackson.databind)
    This mapper (or, data binder, or codec) provides functionality for converting between Java objects (
  • Window (java.awt)
    A Window object is a top-level window with no borders and no menubar. The default layout for a windo
  • Permission (java.security)
    Abstract class for representing access to a system resource. All permissions have a name (whose inte
  • StringTokenizer (java.util)
    The string tokenizer class allows an application to break a string into tokens. The tokenization met
  • TimeUnit (java.util.concurrent)
    A TimeUnit represents time durations at a given unit of granularity and provides utility methods to
  • HttpServletRequest (javax.servlet.http)
    Extends the javax.servlet.ServletRequest interface to provide request information for HTTP servlets.
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now