List of usage examples for java.math BigDecimal valueOf
public static BigDecimal valueOf(double val)
From source file:net.sourceforge.fenixedu.domain.Guide.java
@Deprecated public void setTotal(Double total) { if (total != null) { setTotalBigDecimal(BigDecimal.valueOf(total)); } else {//from ww w .jav a 2s. com setTotalBigDecimal(null); } }
From source file:net.eusashead.hateoas.hal.response.impl.HalResponseBuilderImplTest.java
@Test public void testConvertWithRepresentationWriter() throws Exception { // Create a test object Order order = new Order(1, BigDecimal.valueOf(12.32d), new Date(123456789l)); // Create a HalGetResponseBuilder HalResponseBuilderImpl builder = new HalResponseBuilderImpl(representationFactory, request); // Create a response with a Representation ResponseEntity<Representation> response = builder.convert(order, new OrderRepresentationWriter()) .etag(order.getDate()).lastModified(order.getDate()).expireIn(1000000).build(); // Check the headers assertHeaders(response);/*w w w. j a v a2 s .c o m*/ // Check the body Assert.assertEquals("/order/1", response.getBody().getLinkByRel("self").getHref()); Assert.assertEquals("1", response.getBody().getValue("id").toString()); Assert.assertEquals("12.32", response.getBody().getValue("total").toString()); Assert.assertEquals(new Date(123456789l).toString(), response.getBody().getValue("date").toString()); }
From source file:de.metas.ui.web.handlingunits.process.WEBUI_M_HU_Transform.java
private void actionSplitCUToNew(final HUDocumentView cuRow) { Check.assume(cuRow.isCU(), "CU Row: {}", cuRow); final IMutableHUContext huContextInitial = handlingUnitsBL.createMutableHUContextForProcessing(this); final IHUSplitBuilder splitBuilder = new HUSplitBuilder(huContextInitial); ///* w w w.j a v a 2 s .c om*/ // "Our" HU, the one which the user selected for split final I_M_HU huToSplit = InterfaceWrapperHelper.create(getCtx(), cuRow.getM_HU_ID(), I_M_HU.class, ITrx.TRXNAME_ThreadInherited); splitBuilder.setHUToSplit(huToSplit); // // DocumentLine / Trx Referenced model (if available) final IHUDocumentLine documentLine = null; // TODO huToSplitKey.findDocumentLineOrNull(); splitBuilder.setDocumentLine(documentLine); splitBuilder.setCUTrxReferencedModel(documentLine == null ? null : documentLine.getTrxReferencedModel()); splitBuilder.setCUProduct(InterfaceWrapperHelper.create(getCtx(), cuRow.getM_Product_ID(), I_M_Product.class, ITrx.TRXNAME_None)); splitBuilder.setCUQty(cuRow.getQtyCU()); splitBuilder.setCUUOM( InterfaceWrapperHelper.create(getCtx(), cuRow.getC_UOM_ID(), I_C_UOM.class, ITrx.TRXNAME_None)); splitBuilder.setCUPerTU(p_QtyCU); splitBuilder.setTUPerLU(p_QtyTU); splitBuilder.setMaxLUToAllocate(BigDecimal.valueOf(Integer.MAX_VALUE)); final I_M_HU_PI_Item_Product tuPI_ItemProduct = InterfaceWrapperHelper.create(getCtx(), p_M_HU_PI_Item_Product_ID, I_M_HU_PI_Item_Product.class, ITrx.TRXNAME_None); final I_M_HU_PI_Item tuPI_Item = tuPI_ItemProduct.getM_HU_PI_Item(); splitBuilder.setTU_M_HU_PI_Item(tuPI_Item); // LU final I_M_HU_PI tuPI = tuPI_Item.getM_HU_PI_Version().getM_HU_PI(); final I_C_BPartner bpartner = huToSplit.getC_BPartner(); final I_M_HU_PI_Item luPI_Item = handlingUnitsDAO .retrieveParentPIItemsForParentPI(tuPI, X_M_HU_PI_Version.HU_UNITTYPE_LoadLogistiqueUnit, bpartner) .stream().filter(piItem -> piItem.getM_HU_PI_Version().getM_HU_PI_ID() == p_M_LU_HU_PI_ID) .findFirst().orElseThrow( () -> new AdempiereException(tuPI.getName() + " cannot be loaded to " + p_M_LU_HU_PI_ID)); splitBuilder.setLU_M_HU_PI_Item(luPI_Item); final List<I_M_HU> husAfterSplit = splitBuilder.split(); getView().addHUsAndInvalidate(husAfterSplit); }
From source file:de.hybris.platform.acceleratorservices.payment.cybersource.strategies.impl.DefaultCreateSubscriptionRequestStrategy.java
protected SubscriptionSignatureData getRequestSubscriptionSignatureData( final SubscriptionFrequencyEnum frequencyEnum) { final SubscriptionSignatureData data = new SubscriptionSignatureData(); final SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMdd", Locale.getDefault()); data.setRecurringSubscriptionInfoAmount(BigDecimal.valueOf(0)); data.setRecurringSubscriptionInfoAutomaticRenew(Boolean.FALSE); data.setRecurringSubscriptionInfoFrequency(frequencyEnum.getStringValue()); data.setRecurringSubscriptionInfoNumberOfPayments(Integer.valueOf(0)); data.setRecurringSubscriptionInfoStartDate(formatter.format(new Date())); data.setSharedSecret(getSharedSecret()); return data;/*from www . j a v a 2 s .c o m*/ }
From source file:org.openvpms.archetype.rules.stock.ChargeStockUpdaterTestCase.java
/** * Verifies that the stock is updated correctly if referred to by two different items in a transaction. */// w w w . java 2s .c o m @Test public void testMultipleStockUpdatesInTxn() { final List<FinancialAct> acts = new ArrayList<FinancialAct>(createInvoice()); final FinancialAct item1 = acts.get(1); final FinancialAct item2 = FinancialTestHelper.createChargeItem(CustomerAccountArchetypes.INVOICE_ITEM, patient, product, BigDecimal.ONE); addStockLocation(item2); acts.add(item2); BigDecimal initialQuantity = BigDecimal.ZERO; BigDecimal quantity = BigDecimal.valueOf(5); item1.setQuantity(quantity); item2.setQuantity(quantity); checkEquals(initialQuantity, getStock(stockLocation, product)); BigDecimal expected = getQuantity(initialQuantity, quantity.add(quantity), false); TransactionTemplate template = new TransactionTemplate(txnManager); template.execute(new TransactionCallbackWithoutResult() { @Override protected void doInTransactionWithoutResult(TransactionStatus status) { save(acts); } }); checkEquals(expected, getStock(stockLocation, product)); template.execute(new TransactionCallbackWithoutResult() { @Override protected void doInTransactionWithoutResult(TransactionStatus status) { item1.setQuantity(BigDecimal.ONE); save(item1); remove(item2); } }); expected = getQuantity(initialQuantity, BigDecimal.ONE, false); checkEquals(expected, getStock(stockLocation, product)); }
From source file:logic.EntityCar.java
public EntityCar(List<BaseParam> bpList, Set<String> staticUids, String radCore, String radColor, Car car, String markTitle, String modelTitle, String carTitle, BigDecimal carPrice, IdealEntity ie, BigDecimal moneyFound, AStrategy1 a1, AStrategy2 a2, BStrategy1 b1, BStrategy2 b2, ToxicParamType paramTox1, ToxicParamType paramTox2, ToxicValueType valueTox1, ToxicValueType valueTox2, ResourceProfitability resPropf, ResourceStaticType resStatType, Perception percType) { this.car = car; this.markTitle = markTitle; this.modelTitle = modelTitle; this.carTitle = carTitle; this.basePrice = carPrice; if (moneyFound == null) { this.moneyFound = BigDecimal.valueOf(0); } else {/*from w ww .java 2 s . c om*/ this.moneyFound = moneyFound; } this.moneyFound = moneyFound.subtract(basePrice); fullPrice = basePrice; this.ie = ie; this.a1 = a1; this.a2 = a2; this.b1 = b1; this.b2 = b2; this.radCore = radCore; this.radColor = radColor; /*suplog+=" pt1="+paramTox1+"; "; suplog+=" pv1="+valueTox1+"; "; suplog+=" pt2="+paramTox2+"; "; suplog+=" pv2="+valueTox2+"; ";*/ /*if (paramTox1 != null && !ToxicParamType.NOSTRATEGY.equals(paramTox1)) { //this.minParamToxic1 = BigDecimal.valueOf(getMinToxParam(paramTox1)); } else { this.minParamToxic1 = null; }*/ //this.minParamToxic2=BigDecimal.valueOf(getMinToxParam(paramTox2)); //this.minValueToxic1 = BigDecimal.valueOf(getMinToxVal(ToxicValueType.CLEAR)); /*if (valueTox1 != null && !ToxicValueType.NOSTRATEGY.equals(valueTox1)) { //this.minValueToxic1 = BigDecimal.valueOf(getMinToxVal(valueTox1)); } else { this.minValueToxic1 = null; }*/ //this.minValueToxic2=BigDecimal.valueOf(getMinToxVal(valueTox2)); if (paramTox1 != null && !ToxicParamType.NOSTRATEGY.equals(paramTox1)) { this.minParamToxic1 = BigDecimal.valueOf(getMinToxParam(paramTox1)); } else { this.minParamToxic1 = null; } if (valueTox1 != null && !ToxicValueType.NOSTRATEGY.equals(valueTox1)) { this.minValueToxic1 = BigDecimal.valueOf(getMinToxVal(valueTox1)); } else { this.minValueToxic1 = null; } if (paramTox2 != null && !ToxicParamType.NOSTRATEGY.equals(paramTox2)) { this.minParamToxic2 = BigDecimal.valueOf(getMinToxParam(paramTox2)); } else { this.minParamToxic2 = null; } if (valueTox2 != null && !ToxicValueType.NOSTRATEGY.equals(valueTox2)) { this.minValueToxic2 = BigDecimal.valueOf(getMinToxVal(valueTox2)); } else { this.minValueToxic2 = null; } this.percType = percType; this.allParams = bpList; this.staticUids = staticUids; this.resPropf = resPropf; this.resStatType = resStatType; }
From source file:Main.java
public static BigDecimal getSeconds(XMLGregorianCalendar x) { BigDecimal fractional = x.getFractionalSecond(); if (fractional == null) fractional = BigDecimal.ZERO; BigDecimal whole = BigDecimal.valueOf(x.getSecond()); return whole.add(fractional); }
From source file:com.feilong.core.bean.ConvertUtilTest.java
/** * Test to big decimal./* w w w . j ava 2 s . co m*/ */ @Test public void testToBigDecimal() { assertEquals(null, toBigDecimal(null)); assertEquals(BigDecimal.valueOf(1111), toBigDecimal(1111)); assertEquals(BigDecimal.valueOf(0.1), toBigDecimal(0.1)); }
From source file:de.hybris.platform.b2bacceleratorfacades.order.impl.DefaultCartFacade.java
private PriceData buildZeroPrice() { final PriceData price = new PriceData(); price.setValue(BigDecimal.valueOf(0L)); return price; }
From source file:com.workday.autoparse.json.demo.InstanceUpdaterTest.java
@Test public void testBigNumbersFromStrings() { TestObject testObject = new TestObject(); testObject.myBigDecimal = BigDecimal.valueOf(1.1); testObject.myBigInteger = BigInteger.valueOf(1); Map<String, Object> updates = new HashMap<>(); updates.put("myBigDecimal", "2.2"); updates.put("myBigInteger", "2"); TestObject$$JsonObjectParser.INSTANCE.updateInstanceFromMap(testObject, updates, CONTEXT); assertEquals("myBigDecimal", BigDecimal.valueOf(2.2), testObject.myBigDecimal); assertEquals("myBigInteger", BigInteger.valueOf(2), testObject.myBigInteger); }