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:pe.gob.mef.gescon.hibernate.impl.PerfilDaoImpl.java

@Override
public List<Mtperfil> getMtperfilsActived() throws Exception {
    DetachedCriteria criteria = DetachedCriteria.forClass(Mtperfil.class);
    criteria.add(Restrictions.eq("nactivo", BigDecimal.ONE));
    return (List<Mtperfil>) getHibernateTemplate().findByCriteria(criteria);
}

From source file:com.webbfontaine.valuewebb.action.pricedb.mp.MPFillUtils.java

private static void setValuesForVM(MarketPrice mp) {
    String vmCode = StringUtils.trimToEmpty(mp.getVmRuleCode());

    mp.setRetailerPriceCur(null);//from w  w w .  j  a  v a  2 s  .c o  m
    switch (vmCode) {
    case "4":
        mp.setFob(null);
        mp.setFobUSD(null);
        mp.setRetailerPriceCur(Utils.getNationalCurrencyName());
        mp.setRetailPriceCurExcRate(BigDecimal.ONE);
        break;
    case "6":
    case "V":
        mp.setRetailerPrice(null);
        mp.setRetailerRate(null);

        clearCalculableFields(mp);
        break;
    case "X":
        mp.setRetailerPriceUsd(null);
        mp.setRetailerRate(null);
        mp.setFobUSD(null);

        clearCalculableFields(mp);
        break;
    default:
        LOGGER.debug("VM is unknown or not set {}", vmCode);
    }
}

From source file:org.excalibur.discovery.jackson.databind.test.JsonYamlObjectMapperTest.java

public void must_create_an_valid_yaml() throws Exception {
    ApplicationDescriptor description = new ApplicationDescriptor(UUID.randomUUID().toString()).setName("sw");

    description.setUser(new User().setUsername("user"));
    description.setRequirements(new Requirements().setMaximalCostPerHour(BigDecimal.ONE).setMemorySize(4)
            .setNumberOfCpuCores(4).setPlatform(Platform.LINUX));

    description/*from w  w w  .j  av a  2  s . c  o  m*/
            .addCloud(new Cloud().setName("ec2").setProvider(new ProviderSupport().setName("amazon"))
                    .setAccessKey(new AccessKey("a", "bc"))
                    .addRegion(new Region().setName("us-east-1").addZone(new Zone().setName("us-east-1a")))
                    .addAllInstanceTypes(new InstanceTypeReq().setName("m3.medium").setNumberOfInstances(1)))
            .addCloud(new Cloud().setName("gce").setProvider(new ProviderSupport().setName("google"))
                    .setAccessKey(new AccessKey("b", "de"))
                    .addRegion(new Region().setName("us").addZone(new Zone().setName("us-central-1a"))));

    marshallAndUnmarshall(description);
}

From source file:pe.gob.mef.gescon.hibernate.impl.ParametroDaoImpl.java

@Override
public List<Mtparametro> getMtparametrosActived() throws Exception {
    DetachedCriteria criteria = DetachedCriteria.forClass(Mtparametro.class);
    criteria.add(Restrictions.eq("nactivo", BigDecimal.ONE));
    return (List<Mtparametro>) getHibernateTemplate().findByCriteria(criteria);
}

From source file:org.brocalc.calculator.BrokerageCalculatorSIT.java

@Test
public void testBrokerSchedule() {
    Broker broker = new Broker("Test-Broker");
    TradeInfo tradeInfo = mock(TradeInfo.class);
    when(tradeInfo.getBroker()).thenReturn(broker);
    when(tradeInfo.getCurrency()).thenReturn(Currency.getInstance("ZAR"));
    when(tradeInfo.getUsdAmount()).thenReturn(new BigDecimal(13000000));
    BrokerageAmount brokerageAmount = brokerageSchedule.calculateBrokerage(tradeInfo);

    assertEquals("USD", brokerageAmount.getCurrency().getCurrencyCode());
    assertEquals(BigDecimal.ONE.setScale(2), brokerageAmount.getAmount());
}

From source file:org.efaps.esjp.assets.LifecycleCostAbstract_Base.java

protected void createCost(final Parameter _parameter) throws EFapsException {
    // Sales-Configuration
    final Instance baseCurrInst = Currency.getBaseCurrency();

    final Instance rateCurrInst = _parameter.getParameterValue("rateCurrencyLink") == null ? baseCurrInst
            : Instance.get(CIERP.Currency.getType(), _parameter.getParameterValue("rateCurrencyLink"));

    final Object[] rateObj = new BigDecimal[] { BigDecimal.ONE, BigDecimal.ONE };
    final BigDecimal rate = ((BigDecimal) rateObj[0]).divide((BigDecimal) rateObj[1], 12,
            BigDecimal.ROUND_HALF_UP);

    final DecimalFormat format = getFormatInstance();
    final Insert insert = new Insert(getType4CostCreate(_parameter));
    insert.add(CIAssets.LifecycleCostAbstract.AssetLinkAbstract, _parameter.getInstance().getId());
    insert.add(CIAssets.LifecycleCostAbstract.RateCurrencyLink, rateCurrInst.getId());
    insert.add(CIAssets.LifecycleCostAbstract.CurrencyLink, baseCurrInst.getId());
    insert.add(CIAssets.LifecycleCostAbstract.Rate, rateObj);

    final String date = _parameter
            .getParameterValue(getFieldName4Attribute(_parameter, CIAssets.LifecycleCostAbstract.Date.name));
    if (date != null) {
        insert.add(CIAssets.LifecycleCostAbstract.Date, date);
    }/*from w ww  .  ja va2  s  .c  o  m*/

    final String rateAmountStr = _parameter.getParameterValue(
            getFieldName4Attribute(_parameter, CIAssets.LifecycleCostAbstract.RateAmount.name));
    if (rateAmountStr != null) {
        try {
            final BigDecimal rateAmount = (BigDecimal) format.parse(rateAmountStr);
            insert.add(CIAssets.LifecycleCostAbstract.RateAmount, rateAmount);
            insert.add(CIAssets.LifecycleCostAbstract.Amount,
                    rateAmount.setScale(8, BigDecimal.ROUND_HALF_UP).divide(rate, BigDecimal.ROUND_HALF_UP));
        } catch (final ParseException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
    insert.execute();
}

From source file:cherry.foundation.type.SecureBigDecimalTest.java

@Test
public void testNoneEncoder() {
    Encoder<BigDecimal> encoder = new SecureBigDecimal.NoneEncoder();
    assertThat(encoder.encode(null), is(nullValue()));
    assertThat(encoder.encode(BigDecimal.ONE), is("1"));
    assertThat(encoder.decode(null), is(nullValue()));
    assertThat(encoder.decode("1"), is(BigDecimal.ONE));
}

From source file:org.openhab.ui.basic.internal.render.SetpointRenderer.java

@Override
public EList<Widget> renderWidget(Widget w, StringBuilder sb) throws RenderException {
    Setpoint sp = (Setpoint) w;//from  w  w  w.j a v  a  2s  .c  o  m

    State state = itemUIRegistry.getState(w);
    String newLowerState = state.toString();
    String newHigherState = state.toString();

    // set defaults for min, max and step
    BigDecimal step = sp.getStep();
    if (step == null) {
        step = BigDecimal.ONE;
    }
    BigDecimal minValue = sp.getMinValue();
    if (minValue == null) {
        minValue = BigDecimal.ZERO;
    }
    BigDecimal maxValue = sp.getMaxValue();
    if (maxValue == null) {
        maxValue = BigDecimal.valueOf(100);
    }

    // if the current state is a valid value, we calculate the up and down step values
    if (state instanceof DecimalType) {
        DecimalType actState = (DecimalType) state;
        BigDecimal newLower = actState.toBigDecimal().subtract(step);
        BigDecimal newHigher = actState.toBigDecimal().add(step);
        if (newLower.compareTo(minValue) < 0) {
            newLower = minValue;
        }
        if (newHigher.compareTo(maxValue) > 0) {
            newHigher = maxValue;
        }
        newLowerState = newLower.toString();
        newHigherState = newHigher.toString();
    }

    String unit = getUnitForWidget(w);

    String snippetName = "setpoint";
    String snippet = getSnippet(snippetName);

    snippet = preprocessSnippet(snippet, w);
    snippet = StringUtils.replace(snippet, "%newlowerstate%", newLowerState);
    snippet = StringUtils.replace(snippet, "%newhigherstate%", newHigherState);
    snippet = StringUtils.replace(snippet, "%value%", getValue(w));
    snippet = StringUtils.replace(snippet, "%minValue%", minValue.toString());
    snippet = StringUtils.replace(snippet, "%maxValue%", maxValue.toString());
    snippet = StringUtils.replace(snippet, "%step%", step.toString());
    snippet = StringUtils.replace(snippet, "%unit%", unit);

    // Process the color tags
    snippet = processColor(w, snippet);

    sb.append(snippet);
    return null;
}

From source file:pe.gob.mef.gescon.hibernate.impl.CategoriaDaoImpl.java

@Override
public List<Mtcategoria> getMtcategoriasActived() throws Exception {
    DetachedCriteria criteria = DetachedCriteria.forClass(Mtcategoria.class);
    criteria.add(Restrictions.eq("nestado", BigDecimal.ONE));
    criteria.addOrder(Order.asc("nnivel"));
    criteria.addOrder(Order.asc("ncategoriaid"));
    return (List<Mtcategoria>) getHibernateTemplate().findByCriteria(criteria);
}

From source file:org.finra.datagenerator.engine.scxml.tags.RangeExtension.java

/**
 * Performs variable assignments from a set of values
 *
 * @param action            a RangeTag Action
 * @param possibleStateList a current list of possible states produced so far from expanding a model state
 * @return the cartesian product of every current possible state and the set of values specified by action
 *///from  w  w  w.j av a2  s .c o  m
public List<Map<String, String>> pipelinePossibleStates(RangeTag action,
        List<Map<String, String>> possibleStateList) {
    String variable = action.getName();
    BigDecimal from = new BigDecimal(action.getFrom());
    BigDecimal to = new BigDecimal(action.getTo());
    BigDecimal step;
    if (action.getStep() != null) {
        step = new BigDecimal(action.getStep());
    } else {
        step = BigDecimal.ONE;
    }

    List<BigDecimal> rangeValues = new ArrayList<>();
    if (step.signum() == 1) {
        for (BigDecimal current = from; current.compareTo(to) <= 0; current = current.add(step)) {
            rangeValues.add(current);
        }
    } else if (step.signum() == -1) {
        for (BigDecimal current = from; current.compareTo(to) >= 0; current = current.add(step)) {
            rangeValues.add(current);
        }
    } else {
        rangeValues.add(from);
    }

    //take the product
    List<Map<String, String>> productTemp = new LinkedList<>();
    for (Map<String, String> p : possibleStateList) {
        for (BigDecimal value : rangeValues) {
            HashMap<String, String> n = new HashMap<>(p);
            n.put(variable, value.toString());
            productTemp.add(n);
        }
    }

    return productTemp;
}