Example usage for java.math BigDecimal ONE

List of usage examples for java.math BigDecimal ONE

Introduction

In this page you can find the example usage for java.math BigDecimal ONE.

Prototype

BigDecimal ONE

To view the source code for java.math BigDecimal ONE.

Click Source Link

Document

The value 1, with a scale of 0.

Usage

From source file:org.apache.fineract.portfolio.servicecharge.util.ServiceChargeOperationUtils.java

public static BigDecimal divideNonZeroValues(BigDecimal operand, BigDecimal divisor) {
    if (operand == null) {
        return BigDecimal.ONE;
    }//from   ww  w  .j ava2s.co  m
    if (divisor != null && !divisor.equals(BigDecimal.ZERO)) {
        operand = operand.divide(divisor, RoundingMode.HALF_UP);
    }
    return operand;
}

From source file:com.github.fge.jsonschema.keyword.digest.helpers.NumericDigester.java

private static boolean valueIsLong(final JsonNode node) {
    if (!node.canConvertToLong())
        return false;

    if (NodeType.getNodeType(node) == NodeType.INTEGER)
        return true;

    return node.decimalValue().remainder(BigDecimal.ONE).compareTo(BigDecimal.ZERO) == 0;
}

From source file:org.alfresco.extension.bulkimport.source.sample.SampleSourceImportItem.java

private final static NavigableSet<SampleSourceImportItemVersion> synthesiseVersions(final String name,
        final boolean isDirectory, final int numVersions) {
    NavigableSet<SampleSourceImportItemVersion> result = new TreeSet<>();

    // Add at least one version
    result.add(new SampleSourceImportItemVersion(name, isDirectory, BigDecimal.ONE));

    if (!isDirectory && numVersions > 1) {
        for (int i = 1; i < numVersions; i++) {
            result.add(new SampleSourceImportItemVersion(name, isDirectory, BigDecimal.valueOf(i + 1)));
        }/*from   w w  w  . j a v a 2s  .  co  m*/
    }

    return (result);
}

From source file:com.aw.core.db.support.WhereBuilder2.java

public void filterForce(String sqlFiltro) {
    filter(BigDecimal.ONE, sqlFiltro, null);
}

From source file:com.webbfontaine.valuewebb.action.tt.dataimporter.TTMergeTest.java

private static TtGen getTT() {
    TtGen ttGen = new TtGen();
    ttGen.setAppTin(RandomStringUtils.random(5));
    ttGen.setAppAdr(RandomStringUtils.random(5));

    TtInv inv = new TtInv();
    inv.setTtGen(ttGen);//  w  ww . j av a  2s .  co m
    inv.setInvCur(RandomStringUtils.random(3));
    inv.setInsuranceF(BigDecimal.ONE);

    ttGen.getTtInvs().add(inv);

    Pd pd = new Pd();
    pd.setTtGen(ttGen);
    pd.setTtInv(inv);

    pd.setHsCodeD(RandomStringUtils.random(10));
    inv.getPds().add(pd);

    return ttGen;
}

From source file:com.qcadoo.model.api.BigDecimalUtils.java

/**
 * Converts value, if null returns one/*from   w w  w.jav a  2  s  .co  m*/
 * 
 * @param value
 *            value
 * 
 * @return value or one
 */
public static BigDecimal convertNullToOne(final Object value) {
    if (value == null) {
        return BigDecimal.ONE;
    }
    if (value instanceof BigDecimal) {
        return (BigDecimal) value;
    }
    return BigDecimal.valueOf(Double.valueOf(value.toString()));

}

From source file:es.logongas.encuestas.modelo.resultados.InferenciaEstadistica.java

public InferenciaEstadistica(EstadisticaDescriptiva estadisticaDescriptiva, BigDecimal nivelConfianza,
        int numDecimals) {
    this.numDecimals = numDecimals;
    if (nivelConfianza.compareTo(BigDecimal.ZERO) <= 0) {
        throw new IllegalArgumentException("El nivelConfianza debe ser mayor que 0");
    }/* www.  java 2  s.c  om*/
    if (nivelConfianza.compareTo(BigDecimal.ONE) >= 0) {
        throw new IllegalArgumentException("El nivelConfianza debe ser menor que 1");
    }

    TDistribution tDistribution = new TDistribution(estadisticaDescriptiva.getNumMuestras() - 1);
    double t = tDistribution.inverseCumulativeProbability(nivelConfianza.doubleValue());
    BigDecimal delta = new BigDecimal(t * (estadisticaDescriptiva.getDesviacionEstandar().doubleValue()
            / Math.sqrt(estadisticaDescriptiva.getNumMuestras())));

    BigDecimal min = estadisticaDescriptiva.getMedia().subtract(delta).setScale(this.numDecimals,
            RoundingMode.HALF_UP);
    BigDecimal max = estadisticaDescriptiva.getMedia().add(delta).setScale(this.numDecimals,
            RoundingMode.HALF_UP);
    intervaloConfianzaMedia = new IntervaloConfianza(min, max, nivelConfianza);

}

From source file:com.startup.musicstore.test.repository.CustomerInvoiceRepositoryTest.java

@Test(enabled = true)
public void createInvoice() {
    //Date d = new 
    repo = ctx.getBean(CustomerInvoiceRepository.class);

    CustomerInvoice cust = new CustomerInvoice.Builder(new java.util.Date()).amount(BigDecimal.ONE)

            .invoicestatus("Hello").order(null).builder();
    repo.save(cust);/*from ww  w.  j a va 2  s.  c  om*/
    id = cust.getId();
    Assert.assertNotNull(cust);

}

From source file:com.catalog.repository.util.DomainUtil.java

public static Article getTestArticle() {
    Article article = new Article();
    article.setName(RandomStringUtils.random(RANDOM_LENGTH));
    article.setShortDescription(RandomStringUtils.random(RANDOM_LENGTH));
    article.setLongDescription(RandomStringUtils.random(RANDOM_LENGTH));
    article.setCreatedDate(Calendar.getInstance().getTime());
    article.setPhasedOutDate(Calendar.getInstance().getTime());
    article.setDeletedDate(Calendar.getInstance().getTime());
    article.setPrice(BigDecimal.ONE);
    article.setBarcode(RandomStringUtils.randomNumeric(RANDOM_LENGTH));
    return article;
}

From source file:md.ibanc.rm.controllers.rest.RestExchangeRateController.java

@RequestMapping(value = "/rest/valueExchangeRate", method = RequestMethod.GET)
public ResponseEntity<List<ExchangeRate>> getAllExchangeRate() {

    ExchangeRate exchangeRate = new ExchangeRate();
    exchangeRate.setBuyCurs(BigDecimal.ONE);
    exchangeRate.setDataIns(new Date());
    exchangeRate.setOfficialCurs(BigDecimal.TEN);
    exchangeRate.setSellCurs(BigDecimal.TEN);
    exchangeRateService.save(exchangeRate);

    List<ExchangeRate> ExchangeRateRestList = (ArrayList<ExchangeRate>) exchangeRateService.findAll();

    return new ResponseEntity<>(ExchangeRateRestList, HttpStatus.OK);
}