protected PersistentQuantity doInvertSign(final PersistentQuantity q) throws PersistenceException { final Fraction amount = FractionManager.getTheFractionManager().invertSign(q.getAmount()); final PersistentQuantity res = Quantity.createQuantity(amount, q.getUnit()); getThis().getQuantities().add(res); return res; }
@Override public PersistentQuantity createQuantity( final PersistentAbsUnit unit, final common.Fraction amount) throws PersistenceException { // amount in FractionManager suchen oder neu erstellen. final String fractionStroke = "/"; final String enumeratorString = amount.getEnumerator().toString(); final String denominatorString = amount.getEnumerator().toString(); final String fractionSearchString = enumeratorString + fractionStroke + denominatorString; common.Fraction persistentAmount; try { persistentAmount = FractionManager.getTheFractionManager().getFraction(fractionSearchString); } catch (final NotFoundException e) { persistentAmount = amount; try { FractionManager.getTheFractionManager().addFraction(fractionSearchString, persistentAmount); } catch (final DoubleDefinitionException e1) { System.out.println("error while fraction creation"); } } final PersistentQuantity newQuantity = Quantity.createQuantity(amount, unit); getThis().getQuantities().add(newQuantity); return newQuantity; }