Java BigDecimal Negate negateIfTrue(final boolean condition, final BigDecimal value)

Here you can find the source of negateIfTrue(final boolean condition, final BigDecimal value)

Description

Returns the negate of the value if condition is true, handles null.

License

Apache License

Declaration

public static BigDecimal negateIfTrue(final boolean condition, final BigDecimal value) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.math.BigDecimal;

public class Main {
    /**/*w ww .  ja  v  a2s.c o m*/
     * Returns the negate of the value if condition is true, handles null.
     */
    public static BigDecimal negateIfTrue(final boolean condition, final BigDecimal value) {
        return condition ? negate(value) : value;
    }

    /**
     * Returns the negate of the value, handles null.
     */
    public static BigDecimal negate(final BigDecimal value) {
        return value != null ? value.negate() : null;
    }
}

Related

  1. negate(BigDecimal amount)
  2. negate(BigDecimal decimal)
  3. negate(final BigDecimal value)
  4. negation(BigDecimal bigDecimal)