/** * Returns the quotient of this unit with the one specified. * * @param that the unit divisor. * @return <code>this / that</code> */ public final Unit<? extends Quantity> divide(Unit<?> that) { return this.times(that.inverse()); }
/** * Returns the quotient of this unit with the one specified. * * @param that the unit divisor. * @return <code>this / that</code> */ public final Unit<? extends Quantity> divide(Unit<?> that) { return this.times(that.inverse()); }
static public Unit<? extends Quantity> p(Unit<? extends Quantity> unit){ return log((Unit)unit.inverse()); } }
public static Unit<?> getMostGeneralUnit(List<Unit<?>> candidateUnits) { candidateUnits.sort( (o1, o2) -> { UnitConverter converterTo = o1.inverse().getConverterTo(o2.inverse()); if (converterTo.convert(1) > 1) { return -1; } else { return 1; } }); return candidateUnits.isEmpty() ? null : candidateUnits.get(0); }
/** * Returns the quotient of this unit with the one specified. * * @param that the unit divisor. * @return <code>this / that</code> */ public final Unit<? extends Quantity> divide(Unit<?> that) { return this.times(that.inverse()); }
public static Unit<?> findDurationUnit(String description) { Set<String> tokens = Sets.newHashSet(description.toLowerCase().split(NON_LETTER_REGEX)); List<Unit<?>> candidateUnits = new ArrayList<>(); for (Unit<?> unit : DURATION_UNITS) { if (tokens.contains(unit.inverse().toString().toLowerCase())) { candidateUnits.add(unit); } } return getMostGeneralUnit(candidateUnits); }
public static Unit<?> findDurationUnit(String description) { Set<String> tokens = Sets.newHashSet(description.toLowerCase().split(NON_LETTER_REGEX)); List<Unit<?>> candidateUnits = new ArrayList<Unit<?>>(); for (Unit<?> unit : DURATION_UNITS) { if (tokens.contains(unit.inverse().toString().toLowerCase())) { candidateUnits.add(unit); } } return getMostGeneralUnit(candidateUnits); }
public void run() { Unit<?> inverse = INV_LOOKUP.get(unit); if (inverse == null) { inverse = unit.inverse(); INV_LOOKUP.put(unit, inverse); } } });
AmountWrapper getInternalAmount(String description) { Unit<?> unit = CategoryMapperUtil.findDurationUnit(description); if (unit != null && unit.isCompatible(STANDARD_PER_WEEK_UNIT)) { return AmountWrapper.create( Amount.rangeOf((double) 3, NonSI.DAY.inverse().getConverterTo(unit).convert(1) - 1, unit) .to(STANDARD_PER_WEEK_UNIT), false); } return null; } }
AmountWrapper getInternalAmount(String description) { Unit<?> unit = CategoryMapperUtil.findDurationUnit(description); if (unit != null && unit.isCompatible(STANDARD_PER_WEEK_UNIT)) { return AmountWrapper .create(Amount.rangeOf((double) 3, NonSI.DAY.inverse().getConverterTo(unit).convert(1) - 1, unit) .to(STANDARD_PER_WEEK_UNIT), false); } return null; } }
UnitConverter multiplier = UnitConverter.IDENTITY; if(!(from).isCompatible(to) && (from.inverse()).isCompatible(to)){ fromParent = fromParent.inverse(); multiplier = new MultiplyConverter(-1); UnitConverter multiplier = UnitConverter.IDENTITY; if(!(from).isCompatible(to) && (from).isCompatible(to.inverse())){ toParent = toParent.inverse(); multiplier = new MultiplyConverter(-1);
unit = g.unit.inverse();