List of usage examples for java.math BigDecimal ZERO
BigDecimal ZERO
To view the source code for java.math BigDecimal ZERO.
Click Source Link
From source file:io.seldon.prediction.VariationPredictionStrategy.java
public static VariationPredictionStrategy build(List<Variation> variations) { Map<Range, SimplePredictionStrategy> strategyMap = new LinkedHashMap<>(); BigDecimal ratioTotal = BigDecimal.ZERO; for (Variation var : variations) { ratioTotal = ratioTotal.add(var.ratio); }// ww w . j a v a2 s. c o m BigDecimal currentMax = BigDecimal.ZERO; for (Variation var : variations) { NumberRange range = new NumberRange(currentMax, currentMax.add(var.ratio.divide(ratioTotal, 5, BigDecimal.ROUND_UP))); strategyMap.put(range, var.variationStrategy); currentMax = currentMax.add(var.ratio); } return new VariationPredictionStrategy(strategyMap); }
From source file:com.legstar.mock.client.MockLsfileal.java
/** * Create a response to LSFILEAE execution request. * /*from ww w. ja va 2 s . c om*/ * @param requestMessage the request message * @return formatted response * @throws RequestException if response cannot be built */ public static LegStarMessage getResponse(final LegStarMessage requestMessage) throws RequestException { if (LOG.isDebugEnabled()) { LOG.debug("Building response for program LSFILEAL"); } try { byte[] hostRequest = requestMessage.getDataParts().get(0).getContent(); String namePattern = getRequestName(hostRequest); List<byte[]> customers = FILEA.getCustomers(namePattern); int offset = 0; String hostCharsetName = CobolContext.getDefaultHostCharsetName(); byte[] hostReply = new byte[143 + 79 * customers.size()]; /* reply type */ CobolBinarySimpleConverter.toHostSingle(BigDecimal.ZERO, 2, false, hostReply, offset); offset += 2; /* search duration */ CobolStringSimpleConverter.toHostSingle("00:00:00", hostCharsetName, null, 8, false, hostReply, offset); offset += 8; /* total items */ CobolPackedDecimalSimpleConverter.toHostSingle(new BigDecimal(FILEA.getCustomersNumber()), 5, 8, 0, false, hostReply, offset); offset += 5; /* filler */ offset += 123; /* items number */ CobolPackedDecimalSimpleConverter.toHostSingle(new BigDecimal(customers.size()), 5, 8, 0, false, hostReply, offset); offset += 5; /* items */ for (byte[] customer : customers) { System.arraycopy(customer, 0, hostReply, offset, 79); offset += 79; } LegStarMessage replyMessage = new LegStarMessage(); replyMessage.addDataPart(new CommareaPart(hostReply)); return replyMessage; } catch (HeaderPartException e) { throw new RequestException(e); } catch (CobolConversionException e) { throw new RequestException(e); } }
From source file:com.redhat.rhtracking.web.domain.InvoiceInfo.java
public InvoiceInfo() { this.platformHours = 0; this.platformPrice = BigDecimal.ZERO; this.middlewareHours = 0; this.middlewarePrice = BigDecimal.ZERO; this.workshopHours = 0; this.workshopPrice = BigDecimal.ZERO; }
From source file:Main.java
/** * Subtract one positive Duration from another, larger positive Duration. * @param d1 The larger positive duration * @param d2 The smaller positive duration * @return The difference/*from w w w. j ava 2 s. co m*/ */ private static Duration subtractSmallerPositiveDurationFromLargerPositiveDuration(Duration d1, Duration d2) { BigDecimal s1 = fractionalSeconds(d1); BigDecimal s2 = fractionalSeconds(d2); BigDecimal extraSeconds = s1.subtract(s2); Duration strip1 = stripFractionalSeconds(d1); Duration strip2 = stripFractionalSeconds(d2); Duration stripResult = strip1.subtract(strip2); if (extraSeconds.compareTo(BigDecimal.ZERO) < 0) { stripResult = stripResult.subtract(DURATION_1_SECOND); extraSeconds = extraSeconds.add(BigDecimal.ONE); } BigDecimal properSeconds = BigDecimal.valueOf(stripResult.getSeconds()).add(extraSeconds); return FACTORY.newDuration(true, BigInteger.valueOf(stripResult.getYears()), BigInteger.valueOf(stripResult.getMonths()), BigInteger.valueOf(stripResult.getDays()), BigInteger.valueOf(stripResult.getHours()), BigInteger.valueOf(stripResult.getMinutes()), properSeconds); }
From source file:com.khs.report.Data.java
public Data(String id, Object value) { super();/*ww w .jav a2 s. c o m*/ setId(id); if (value instanceof BigDecimal && ((BigDecimal) value).compareTo(BigDecimal.ZERO) == 0) { setValue(new BigDecimal("0.00")); } else { setValue(value); } }
From source file:com.impetus.kundera.utils.NumericUtils.java
/** * Check if zero/* w ww. ja v a2 s . c o m*/ * @param value value string * @param valueClazz value class * @return */ public static final boolean checkIfZero(String value, Class valueClazz) { boolean returnValue = false; if (value != null && NumberUtils.isNumber(value) && numberTypes.get(valueClazz) != null) { switch (numberTypes.get(valueClazz)) { case INTEGER: returnValue = Integer.parseInt(value) == (NumberUtils.INTEGER_ZERO); break; case FLOAT: returnValue = Float.parseFloat(value) == (NumberUtils.FLOAT_ZERO); break; case LONG: returnValue = Long.parseLong(value) == (NumberUtils.LONG_ZERO); break; case BIGDECIMAL: returnValue = new BigDecimal(value) == (BigDecimal.ZERO); break; case BIGINTEGER: returnValue = new BigInteger(value) == (BigInteger.ZERO); break; case SHORT: returnValue = new Short(value) == (NumberUtils.SHORT_ZERO); break; } } return returnValue; }
From source file:com.wallmart.calculateroute.ApplicationStartup.java
@Override public void onApplicationEvent(final ContextRefreshedEvent event) { // GraphDatabaseService instance = GraphDatabaseServiceSingleton.getInstance(); logger.info("###Startup DB"); GraphDatabaseServiceSingleton.getInstance(); logger.info("###Started DB"); logger.info("###insert and get some info"); GraphDatabase graphdb = new GraphDatabase(); Route r = new Route("test", "A", "B", 10L); graphdb.insertRoute(r);//from w w w . jav a 2s . c o m CalculateRoute cr = graphdb .shortestRouteDistance(new CalculateRoute("test", "A", "B", 10l, BigDecimal.ZERO)); logger.info("###DB working fine"); }
From source file:com.creditcloud.interestbearing.model.InterestBearingUserFundChange.java
public BigDecimal getAbsoluteChangeAmount() { if (changeAmount == null) { return BigDecimal.ZERO; } return changeAmount.abs(); }
From source file:org.openvpms.component.business.service.archetype.assertion.ExpressionAssertionTestCase.java
/** * Tests the {@link ExpressionAssertions} methods when invoked via * archetype service validation.// www . j a v a 2 s . c o m */ @Test public void testAssertions() { Act act = (Act) create("act.expressionAssertions"); assertNotNull(act); ActBean bean = new ActBean(act); bean.setValue("amount", BigDecimal.ZERO); try { validateObject(act); fail("Expected validation to fail"); } catch (ValidationException expected) { assertEquals(3, expected.getErrors().size()); checkError(expected, 0, "act.expressionAssertions", "amount", "Amount must be > 0"); checkError(expected, 1, "act.expressionAssertions", "value1", "Value1 must be < amount"); checkError(expected, 2, "act.expressionAssertions", "value2", "Value2 must be < amount"); } bean.setValue("amount", new BigDecimal("100.00")); validateObject(act); }
From source file:com.github.fge.jsonschema.syntax.checkers.helpers.DivisorSyntaxChecker.java
@Override protected void checkValue(final Collection<JsonPointer> pointers, final ProcessingReport report, final SchemaTree tree) throws ProcessingException { final JsonNode node = getNode(tree); final BigDecimal divisor = node.decimalValue(); if (divisor.compareTo(BigDecimal.ZERO) <= 0) report.error(newMsg(tree, "illegalDivisor").put("found", node)); }