List of usage examples for java.lang Double valueOf
@HotSpotIntrinsicCandidate public static Double valueOf(double d)
From source file:com.sc.web.SaleController.java
@RequestMapping(value = URL + "UserApplication", method = RequestMethod.POST) @ApiOperation("(){token,phone?,shopname??address?,lon?,lat,pwd?,pwdagain?,cardno???personname??,contactname???contactphone??telephone?,pax?,{??name:card,name:store,???name:license}") public Result userApplication(HttpServletRequest request, @RequestParam("card") MultipartFile[] cardFiles, @RequestParam("store") MultipartFile[] storeFiles, @RequestParam("license") MultipartFile[] licenseFiles) { String token = request.getParameter("token"); String address = request.getParameter("address"); String pwd = request.getParameter("pwd"); String pwdagain = request.getParameter("pwdagain"); String cardno = request.getParameter("cardno"); String phone1 = request.getParameter("phone"); Long phone = Long.valueOf(request.getParameter("phone")); String lon1 = request.getParameter("lon"); Double lon = Double.valueOf(request.getParameter("lon")); String lat1 = request.getParameter("lat"); Double lat = Double.valueOf(request.getParameter("lat")); String shopname = request.getParameter("shopname"); String personname = request.getParameter("personname"); String contactname = request.getParameter("contactname"); String contactphone = request.getParameter("contactphone"); String telephone = request.getParameter("telephone"); String pax = request.getParameter("pax"); Token tk = jwt.checkJWT(token);/*from ww w . j a va 2 s . c o m*/ if (tk == null) { return GetResult.toJson(101, null, null, null, 0); } if (StringUtils.isBlank(address) || StringUtils.isBlank(pwd) || StringUtils.isBlank(pwdagain) || StringUtils.isBlank(cardno) || StringUtils.isBlank(phone1) || StringUtils.isBlank(lon1) || StringUtils.isBlank(lat1)) { return GetResult.toJson(38, null, null, null, 0); } if (!Objects.equals(pwd, pwdagain)) { return GetResult.toJson(55, null, null, null, 0); } return saleService.UserApplication(tk.getUserId(), phone, address, lon, lat, pwd, cardno, shopname, personname, contactname, contactphone, telephone, pax, cardFiles, storeFiles, licenseFiles); }
From source file:com.c123.billbuddy.client.PaymentFeeder.java
@Transactional public void createPayment() { Random random = new Random(); int userId = (int) (userCount * random.nextDouble()); user = gigaSpace.readById(User.class, new Integer(userId)); int merchantId = (int) (merchantCount * random.nextDouble()); merchant = gigaSpace.readById(Merchant.class, new Integer(merchantId)); if (user != null && merchant != null) { Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(System.currentTimeMillis()); Date date = calendar.getTime(); Double paymentAmount = Double.valueOf(Math.random() * 100); paymentAmount = Math.round(paymentAmount * 100.0) / 100.0; // Check If user valid and have credit limit if (user.getStatus() != AccountStatus.ACTIVE) { log.info("User: " + user.getName() + " status is " + user.getStatus()); } else if (user.getBalance() - paymentAmount < user.getCreditLimit()) { log.info("User: " + user.getName() + " doesn't have credit."); Double addUserBalance = Double.valueOf(Math.random() * 1000); addUserBalance = Math.round(addUserBalance * 100.0) / 100.0; log.info("Add " + addUserBalance + " to user balance"); user.setBalance(user.getBalance() + addUserBalance); gigaSpace.write(user);/*from w w w . j av a 2 s .c om*/ } else { // Withdraw payment amount from user account updateUserBalance(user, paymentAmount); // Deposit payment amount to merchant account updateMerchantReceipts(merchant, paymentAmount); // Create a Payment POJO and set it up. Payment payment = new Payment(); payment.setPayingAccountId(user.getUserAccountId()); payment.setReceivingMerchantId(merchant.getMerchantAccountId()); payment.setDescription(merchant.getCategory().name()); payment.setCreatedDate(date); payment.setPaymentAmount(Double.valueOf(Math.random() * 100)); payment.setPaymentAmount(Math.round(paymentAmount * 100.0) / 100.0); payment.setStatus(TransactionStatus.NEW); // Write the payment object gigaSpace.write(payment); log.info("TransactionWriterTask wrote new transaction between user: " + user.getName() + " and merchant: " + merchant.getName()); } } }
From source file:com.itemanalysis.psychometrics.cfa.AbstractConfirmatoryFactorAnalysisEstimator.java
public double meanSquaredResidual() { double ni = Double.valueOf(nItems).doubleValue(); double temp = 0.0, sum = 0.0; for (int i = 0; i < SIGMA.getRowDimension(); i++) { for (int j = 0; j < SIGMA.getColumnDimension(); j++) { temp = varcov.getEntry(i, j) - SIGMA.getEntry(i, j); sum += temp * temp;/*www . j av a2 s. c o m*/ } } return sum / (ni * ni); }
From source file:hivemall.anomaly.ChangeFinder2DTest.java
@Test public void testCf1d() throws IOException, HiveException { Parameters params = new Parameters(); params.set(LossFunction.logloss);/* w ww.ja v a2 s . c om*/ PrimitiveObjectInspector oi = PrimitiveObjectInspectorFactory.javaDoubleObjectInspector; ListObjectInspector listOI = ObjectInspectorFactory.getStandardListObjectInspector(oi); ChangeFinder2D cf = new ChangeFinder2D(params, listOI); double[] outScores = new double[2]; List<Double> x = new ArrayList<Double>(1); BufferedReader reader = readFile("cf1d.csv.gz"); println("x outlier change"); String line; int i = 1, numOutliers = 0, numChangepoints = 0; while ((line = reader.readLine()) != null) { double d = Double.parseDouble(line); x.add(Double.valueOf(d)); cf.update(x, outScores); printf("%d %f %f %f%n", i, d, outScores[0], outScores[1]); if (outScores[0] > 10.d) { numOutliers++; } if (outScores[1] > 10.d) { numChangepoints++; } x.clear(); i++; } Assert.assertTrue("#outliers SHOULD be greater than 10: " + numOutliers, numOutliers > 10); Assert.assertTrue("#outliers SHOULD be less than 20: " + numOutliers, numOutliers < 20); Assert.assertTrue("#changepoints SHOULD be greater than 0: " + numChangepoints, numChangepoints > 0); Assert.assertTrue("#changepoints SHOULD be less than 5: " + numChangepoints, numChangepoints < 5); }
From source file:com.glaf.activiti.xml.BpmnXmlReader.java
public List<ActivityInfo> read(Element root, String processDefinitionKey) { List<ActivityInfo> activities = new java.util.ArrayList<ActivityInfo>(); Element element = root.element("BPMNDiagram"); if (element != null) { List<?> elements = element.elements("BPMNPlane"); if (elements != null && !elements.isEmpty()) { Iterator<?> iterator = elements.iterator(); while (iterator.hasNext()) { Element elem = (Element) iterator.next(); String attr = elem.attributeValue("bpmnElement"); if (StringUtils.equals(attr, processDefinitionKey)) { List<?> elems = elem.elements("BPMNShape"); if (elems != null && !elems.isEmpty()) { Iterator<?> iter = elems.iterator(); while (iter.hasNext()) { Element em = (Element) iter.next(); Element e = em.element("Bounds"); if (e != null) { ActivityInfo info = new ActivityInfo(); info.setActivityId(em.attributeValue("bpmnElement")); ActivityCoordinates coord = new ActivityCoordinates(); coord.setHeight(Double.valueOf(e.attributeValue("height"))); coord.setWidth(Double.valueOf(e.attributeValue("width"))); coord.setX(Double.valueOf(e.attributeValue("x"))); coord.setY(Double.valueOf(e.attributeValue("y"))); info.setCoordinates(coord); activities.add(info); }//from w w w. j av a 2 s. c om } } } } } } return activities; }
From source file:com.itemanalysis.psychometrics.cfa.MaximumLikelihoodEstimation.java
public double gfi() { double fit = 0.0; double q = Double.valueOf(model.getNumberOfItems()).doubleValue(); RealMatrix I = new IdentityMatrix(nItems); LUDecomposition SLUD = new LUDecomposition(SIGMA); RealMatrix Sinv = SLUD.getSolver().getInverse(); RealMatrix P1 = Sinv.multiply(varcov); RealMatrix D = P1.subtract(I);/* w ww. j a v a 2s. c o m*/ double numerator = D.multiply(D).getTrace(); RealMatrix P2 = Sinv.multiply(varcov); double denom = P2.multiply(P2).getTrace(); fit = 1.0 - numerator / denom; return fit; }
From source file:cn.cdwx.jpa.utils.PropertiesLoader.java
/** * ?DoubleProperty.Null.//w w w. ja va 2 s .com */ public Double getDouble(String key) { String value = getValue(key); if (value == null) { throw new NoSuchElementException(); } return Double.valueOf(value); }
From source file:com.janoz.tvapilib.thetvdb.impl.EpisodeParser.java
public void handleContent(List<String> stack, String content) { if (stack.size() == 1) { if ("id".equals(stack.get(0))) { theTvDbId = Integer.valueOf(content); } else if ("seasonnumber".equals(stack.get(0))) { season = show.getSeason(Integer.parseInt(content)); } else if ("episodenumber".equals(stack.get(0))) { episode = Integer.valueOf(content); } else if ("episodename".equals(stack.get(0))) { title = content;//ww w .ja v a 2 s .co m } else if ("overview".equals(stack.get(0))) { description = content; } else if ("filename".equals(stack.get(0))) { art = new Art(); art.setHd(false); art.setUrl(urlSupplier.getImageUrl(content)); art.setType(Type.THUMB); } else if ("firstaired".equals(stack.get(0))) { airDate = parseDate(content); } else if ("rating".equals(stack.get(0))) { rating = Double.valueOf(content); } } }
From source file:alfio.manager.location.DefaultLocationManager.java
@Override @Cacheable//from w ww .ja v a 2 s. co m public TimeZone getTimezone(String latitude, String longitude) { return Optional .ofNullable( TimeZoneApi .getTimeZone(getApiContext(), new LatLng(Double.valueOf(latitude), Double.valueOf(longitude))) .awaitIgnoreError()) .orElseThrow(() -> new LocationNotFound(String .format("No TimeZone found for location having coordinates: %s,%s", latitude, longitude))); }
From source file:com.aurel.track.fieldType.fieldChange.apply.DoubleFieldChangeApply.java
/** * Sets the workItemBean's attribute//www .j a va 2 s . c o m * @param workItemContext * @param workItemBean * @param fieldID * @param parameterCode * @param value * @return ErrorData if an error is found */ @Override public List<ErrorData> setWorkItemAttribute(WorkItemContext workItemContext, TWorkItemBean workItemBean, Integer parameterCode, Object value) { if (getSetter() == FieldChangeSetters.SET_NULL || getSetter() == FieldChangeSetters.SET_REQUIRED) { return super.setWorkItemAttribute(workItemContext, workItemBean, parameterCode, value); } Double doubleValue = null; try { doubleValue = (Double) value; } catch (Exception e) { LOGGER.warn("Getting the double value for " + value + " failed with " + e.getMessage()); LOGGER.debug(ExceptionUtils.getStackTrace(e)); } switch (getSetter()) { case FieldChangeSetters.SET_TO: workItemBean.setAttribute(activityType, parameterCode, doubleValue); break; case FieldChangeSetters.ADD_IF_SET: if (doubleValue != null) { Double originalValue = (Double) workItemBean.getAttribute(activityType, parameterCode); if (originalValue != null) { double newValue = originalValue.doubleValue() + doubleValue.doubleValue(); workItemBean.setAttribute(activityType, parameterCode, Double.valueOf(newValue)); } } break; case FieldChangeSetters.ADD_OR_SET: if (doubleValue != null) { Double originalValue = (Double) workItemBean.getAttribute(activityType, parameterCode); if (originalValue != null) { double newValue = originalValue.doubleValue() + doubleValue.doubleValue(); workItemBean.setAttribute(activityType, parameterCode, new Double(newValue)); } else { workItemBean.setAttribute(activityType, parameterCode, doubleValue); } } break; } return null; }