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.moserp.billing.domain.BillItem.java

@JsonIgnore
public Price getNetPrice() {
    return price.divide(getVat().add(BigDecimal.ONE));
}

From source file:org.gofleet.openLS.util.Utils.java

/**
 * Envelops an {@link AbstractResponseParametersType} response inside the
 * {@link XLSType}//  www . j  a va2 s . co m
 * 
 * @param element
 * @return
 * @throws AxisFault
 */
@SuppressWarnings({ "rawtypes", "unchecked" })
public static JAXBElement<XLSType> envelop(List<List<AbstractResponseParametersType>> params) {
    XLSType xlsType = new XLSType();
    xlsType.setVersion(BigDecimal.ONE);

    ResponseType responseType = new ResponseType();

    for (List<AbstractResponseParametersType> element : params) {
        for (AbstractResponseParametersType e : element) {
            String responseClass = e.getClass().getSimpleName().toString();
            responseClass = responseClass.substring(0, responseClass.length() - 4);

            JAXBElement<? extends AbstractResponseParametersType> body_ = new JAXBElement(
                    new QName("http://www.opengis.net/xls", responseClass, ""), e.getClass(), e);
            responseType.setResponseParameters(body_);
        }
        responseType.setNumberOfResponses(new BigInteger((new Integer(element.size())).toString()));
        responseType.setRequestID("-1");
        responseType.setVersion("0.9");
        xlsType.getBody().add(new JAXBElement(new QName("http://www.opengis.net/xls", "Response"),
                responseType.getClass(), responseType));
    }

    ResponseHeaderType header = new ResponseHeaderType();
    header.setSessionID("none");

    xlsType.setHeader(new JAXBElement<ResponseHeaderType>(
            new QName("http://www.opengis.net/xls", "ResponseHeader"), ResponseHeaderType.class, header));

    JAXBElement<XLSType> res = new JAXBElement<XLSType>(new QName("http://www.opengis.net/xls", "xls"),
            XLSType.class, xlsType);

    return res;
}

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

@Override
public List<MtestadoBaselegal> getMtestadosBaselegalToLink() throws Exception {
    DetachedCriteria criteria = DetachedCriteria.forClass(MtestadoBaselegal.class);
    criteria.add(Restrictions.eq("nvinculo", BigDecimal.ONE));
    criteria.addOrder(Order.asc("vnombre"));
    return (List<MtestadoBaselegal>) getHibernateTemplate().findByCriteria(criteria);
}

From source file:facade.RoomFacadeTest.java

@BeforeMethod
public void beforeMethod() throws ParseException {
    r1 = new Room();
    r2 = new Room();
    r1.setNumber(1);//from  ww w  .j  a  v a2 s . co m
    r2.setNumber(2);
    r1.setPrice(BigDecimal.ONE);
    r2.setPrice(BigDecimal.TEN);
    r1.setType(RoomType.SingleRoom);
    r2.setType(RoomType.DoubleRoom);
}

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

/**
 * {@inheritDoc}//from ww w.  j  a  va2  s .  com
 */
@Override
public EList<Widget> renderWidget(Widget w, StringBuilder sb) throws RenderException {
    Setpoint sp = (Setpoint) w;

    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 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());

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

    sb.append(snippet);
    return null;
}

From source file:com.devnexus.ting.core.dao.EventSignupDaoTest.java

@Test
public void save() {

    Event event = new Event(42l, "key", "title", true);
    event = eventDao.save(event);//w  w w  .jav a 2s.c  o m

    EventSignup es = new EventSignup();

    es.setEvent(event);

    TicketGroup group1 = new TicketGroup();
    TicketGroup group2 = new TicketGroup();

    group1.setEvent(event);
    group2.setEvent(event);
    group1.setEventSignup(es);
    group2.setEventSignup(es);

    group1.setRegisterFormUrl("abc");
    group2.setRegisterFormUrl("abc");

    group1.setPrice(BigDecimal.ONE);
    group2.setPrice(BigDecimal.ONE);

    group1.setLabel("Test Label 1");
    group2.setLabel("Test Label 2");

    es.getGroups().add(group1);
    es.getGroups().add(group2);

    es = signupDao.save(es);
    Assert.assertNotNull(es.getId());
    es = signupDao.getByEventKey("key");
    Assert.assertNotNull(es);
}

From source file:org.eclipse.smarthome.ui.classic.internal.render.SetpointRenderer.java

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

    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 snippetName = "setpoint";
    String snippet = getSnippet(snippetName);

    snippet = StringUtils.replace(snippet, "%id%", itemUIRegistry.getWidgetId(w));
    snippet = StringUtils.replace(snippet, "%category%", escapeURLPath(itemUIRegistry.getCategory(w)));
    snippet = StringUtils.replace(snippet, "%item%", w.getItem());
    snippet = StringUtils.replace(snippet, "%state%", state.toString());
    snippet = StringUtils.replace(snippet, "%newlowerstate%", newLowerState);
    snippet = StringUtils.replace(snippet, "%newhigherstate%", newHigherState);
    snippet = StringUtils.replace(snippet, "%label%", getLabel(w));
    snippet = StringUtils.replace(snippet, "%format%", getFormat());
    snippet = StringUtils.replace(snippet, "%servletname%", WebAppServlet.SERVLET_NAME);
    snippet = StringUtils.replace(snippet, "%minValue%", minValue.toString());
    snippet = StringUtils.replace(snippet, "%maxValue%", maxValue.toString());
    snippet = StringUtils.replace(snippet, "%step%", step.toString());

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

    sb.append(snippet);
    return null;
}

From source file:org.eclipse.smarthome.ui.webapp.internal.render.SetpointRenderer.java

/**
 * {@inheritDoc}//from  ww  w .j a  va  2 s.  co  m
 */
public EList<Widget> renderWidget(Widget w, StringBuilder sb) throws RenderException {
    Setpoint sp = (Setpoint) w;

    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 snippetName = "setpoint";
    String snippet = getSnippet(snippetName);

    snippet = StringUtils.replace(snippet, "%id%", itemUIRegistry.getWidgetId(w));
    snippet = StringUtils.replace(snippet, "%icon%", escapeURLPath(itemUIRegistry.getIcon(w)));
    snippet = StringUtils.replace(snippet, "%item%", w.getItem());
    snippet = StringUtils.replace(snippet, "%state%", state.toString());
    snippet = StringUtils.replace(snippet, "%newlowerstate%", newLowerState);
    snippet = StringUtils.replace(snippet, "%newhigherstate%", newHigherState);
    snippet = StringUtils.replace(snippet, "%label%", getLabel(w));
    snippet = StringUtils.replace(snippet, "%servletname%", WebAppServlet.SERVLET_NAME);
    snippet = StringUtils.replace(snippet, "%minValue%", minValue.toString());
    snippet = StringUtils.replace(snippet, "%maxValue%", maxValue.toString());
    snippet = StringUtils.replace(snippet, "%step%", step.toString());

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

    sb.append(snippet);
    return null;
}

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//  w  w w  . j av  a2s.  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.coinblesk.server.service.UserTest.java

@Test
@DatabaseSetup("/EmptyDatabase.xml")
@ExpectedDatabase(value = "/UserTestAddUser.xml", assertionMode = DatabaseAssertionMode.NON_STRICT_UNORDERED)
@DatabaseTearDown("/EmptyDatabase.xml")
public void testAddUser() throws Exception {
    UserAccount userAccount = new UserAccount();
    userAccount.setBalance(BigDecimal.ONE).setCreationDate(new Date(1)).setDeleted(false)
            .setEmail("test@test.test").setEmailToken(null).setPassword("blub").setUsername("blib");
    userAccountService.save(userAccount);
}