Created
October 11, 2014 15:49
-
-
Save ldez/5350867ef1b74585cfe1 to your computer and use it in GitHub Desktop.
QueryDSL Collection util for BigDecimal divide Expression
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.math.BigDecimal; | |
import java.math.RoundingMode; | |
import com.mysema.query.support.Expressions; | |
import com.mysema.query.types.ConstantImpl; | |
import com.mysema.query.types.Expression; | |
import com.mysema.query.types.expr.NumberExpression; | |
/** | |
* The Class BigDecimalExpression. | |
*/ | |
public final class BigDecimalExpression { | |
/** The Constant DIVIDE. */ | |
public static final String DIVIDE = "{0}.divide({1}, {2}, {3})"; | |
/** | |
* Instantiates a new big decimal expression. | |
* | |
* @throws InstantiationException the instantiation exception | |
*/ | |
private BigDecimalExpression() throws InstantiationException { | |
throw new InstantiationException(); | |
} | |
/** | |
* Divide. | |
* | |
* @param dividend the dividend | |
* @param divisor the divisor | |
* @param scale the scale | |
* @param roundingMode the rounding mode | |
* @return the number expression | |
*/ | |
public static NumberExpression<BigDecimal> divide(final BigDecimal dividend, final BigDecimal divisor, final int scale, final RoundingMode roundingMode) { | |
return divide(ConstantImpl.create(dividend), ConstantImpl.create(divisor), scale, roundingMode); | |
} | |
/** | |
* Divide. | |
* | |
* @param dividend the dividend | |
* @param divisor the divisor | |
* @param scale the scale | |
* @param roundingMode the rounding mode | |
* @return the number expression | |
*/ | |
public static NumberExpression<BigDecimal> divide(final NumberExpression<BigDecimal> dividend, final BigDecimal divisor, final int scale, final RoundingMode roundingMode) { | |
return divide(dividend, ConstantImpl.create(divisor), scale, roundingMode); | |
} | |
/** | |
* Divide. | |
* | |
* @param dividend the dividend | |
* @param divisor the divisor | |
* @param scale the scale | |
* @param roundingMode the rounding mode | |
* @return the number expression | |
*/ | |
public static NumberExpression<BigDecimal> divide(final BigDecimal dividend, final NumberExpression<BigDecimal> divisor, final int scale, final RoundingMode roundingMode) { | |
return divide(ConstantImpl.create(dividend), divisor, scale, roundingMode); | |
} | |
/** | |
* Divide. | |
* | |
* @param dividend the dividend | |
* @param divisor the divisor | |
* @param scale the scale | |
* @param roundingMode the rounding mode | |
* @return the number expression | |
*/ | |
public static NumberExpression<BigDecimal> divide(final Expression<BigDecimal> dividend, final Expression<BigDecimal> divisor, final int scale, final RoundingMode roundingMode) { | |
return Expressions.numberTemplate(BigDecimal.class, DIVIDE, dividend, divisor, scale, roundingMode); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment