public Dimension getDimension() { return getUnit().getDimension(); }
@SuppressWarnings("unchecked") @Override public boolean equals(@Nullable Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (!(obj instanceof QuantityType)) { return false; } QuantityType<?> other = (QuantityType<?>) obj; if (!quantity.getUnit().getDimension().equals(other.quantity.getUnit().getDimension())) { return false; } else if (compareTo((QuantityType<T>) other) != 0) { return false; } return true; }
@Override public Dimension getDimension() { return lower.getDimension(); } }
@Override public Dimension getDimension() { return parentUnit.getDimension(); }
@Override public Dimension getDimension() { return actualUnit.getDimension(); }
@Override public Dimension getDimension() { return parentUnit.getDimension(); }
public Set<Unit<?>> getUnits() { if (logger.isLoggable(Level.FINEST)) { for (Unit<?> u : units) { logger.log(Level.FINEST, u + "; D: " + u.getDimension() + "; C: " + u.getClass()); } } return units; }
static Set<Unit<?>> getUnitsOfDimension(final Set<Unit<?>> units, Dimension dimension) { if (dimension != null) { Set<Unit<?>> dimSet = new HashSet<Unit<?>>(); for (Unit<?> u : units) { if (dimension.equals(u.getDimension())) { dimSet.add(u); } } return dimSet; } return null; }
static Set<Unit<?>> getUnitsOfDimension(final Set<Unit<?>> units, Dimension dimension) { if (dimension != null) { return units.stream().filter(u -> dimension.equals(u.getDimension())).collect(Collectors.toSet()); } return null; }
static Set<Unit<?>> getUnitsOfDimension(final Set<Unit<?>> units, Dimension dimension) { if (dimension != null) { return units.stream().filter(u -> dimension.equals(u.getDimension())).collect(Collectors.toSet()); } return null; }
@Override public Set<? extends Unit<?>> getUnits(Dimension dimension) { return this.getUnits().stream().filter(unit -> dimension.equals(unit.getDimension())) .collect(Collectors.toSet()); }
@Override public Set<? extends Unit<?>> getUnits(Dimension dimension) { return this.getUnits().stream().filter(unit -> dimension.equals(unit.getDimension())) .collect(Collectors.toSet()); }
@Override public Set<? extends Unit<?>> getUnits(Dimension dimension) { final Set<Unit<?>> set = new HashSet<Unit<?>>(); for (Unit<?> unit : this.getUnits()) { if (dimension.equals(unit.getDimension())) { set.add(unit); } } return set; }
public Dimension getDimension() { return getUnit().getDimension(); }
/** * Returns the units defined in this system having the specified dimension, or an empty set if none. */ @Override public Set<Unit<?>> getUnits(final Dimension dimension) { ArgumentChecks.ensureNonNull("dimension", dimension); final Set<Unit<?>> filtered = new HashSet<>(); for (final Unit<?> unit : getUnits()) { if (dimension.equals(unit.getDimension())) { filtered.add(unit); } } return filtered; } }
private static boolean areFunctionallyIdenticalUnits(Unit<?> left, Unit<?> right) { if (!left.isCompatible(right)) { return false; } Unit<?> divided = left.divide(right); if (!divided.getDimension().equals(Dimension.NONE)) { return false; } return divided.asType(Dimensionless.class).getConverterTo(ONE).equals(IDENTITY); }
@Override public Dimension getDimension() { Dimension dimension = QuantityDimension.NONE; for (int i = 0; i < this.getUnitCount(); i++) { Unit<?> unit = this.getUnit(i); if (this.elements != null && unit.getDimension() != null) { Dimension d = unit.getDimension().pow(this.getUnitPow(i)).root(this.getUnitRoot(i)); dimension = dimension.multiply(d); } } return dimension; }
@Override public Dimension getDimension() { Dimension dimension = QuantityDimension.NONE; for (int i = 0; i < this.getUnitCount(); i++) { Unit<?> unit = this.getUnit(i); if (this.elements != null && unit.getDimension() != null) { Dimension d = unit.getDimension().pow(this.getUnitPow(i)).root(this.getUnitRoot(i)); dimension = dimension.multiply(d); } } return dimension; }
@SuppressWarnings("rawtypes") @Override public final UnitConverter getConverterToAny(Unit<?> that) throws IncommensurableException, UnconvertibleException { if (!isCompatible(that)) throw new IncommensurableException(this + " is not compatible with " + that); AbstractUnit thatAbstr = (AbstractUnit) that; // Since both units are // compatible they must // be both physics // units. DimensionalModel model = DimensionalModel.current(); Unit thisSystemUnit = this.getSystemUnit(); UnitConverter thisToDimension = model.getDimensionalTransform(thisSystemUnit.getDimension()).concatenate(this.getSystemConverter()); Unit thatSystemUnit = thatAbstr.getSystemUnit(); UnitConverter thatToDimension = model.getDimensionalTransform(thatSystemUnit.getDimension()).concatenate(thatAbstr.getSystemConverter()); return thatToDimension.inverse().concatenate(thisToDimension); }
@SuppressWarnings("rawtypes") @Override public final UnitConverter getConverterToAny(Unit<?> that) throws IncommensurableException, UnconvertibleException { if (!isCompatible(that)) throw new IncommensurableException(this + " is not compatible with " + that); AbstractUnit thatAbstr = (AbstractUnit) that; // Since both units are // compatible they must // be both physics // units. DimensionalModel model = DimensionalModel.current(); Unit thisSystemUnit = this.getSystemUnit(); UnitConverter thisToDimension = model.getDimensionalTransform(thisSystemUnit.getDimension()).concatenate(this.getSystemConverter()); Unit thatSystemUnit = thatAbstr.getSystemUnit(); UnitConverter thatToDimension = model.getDimensionalTransform(thatSystemUnit.getDimension()).concatenate(thatAbstr.getSystemConverter()); return thatToDimension.inverse().concatenate(thisToDimension); }