本文整理汇总了Java中java.math.BigDecimal.ONE属性的典型用法代码示例。如果您正苦于以下问题:Java BigDecimal.ONE属性的具体用法?Java BigDecimal.ONE怎么用?Java BigDecimal.ONE使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类java.math.BigDecimal
的用法示例。
在下文中一共展示了BigDecimal.ONE属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getDeltaConcentrationRisk
public static BigDecimal getDeltaConcentrationRisk(RiskClass r, Sensitivity s, List<Sensitivity> all) {
if (r.equals(RiskClass.INTEREST_RATE) && s.getRiskType().equals(RiskType.RISK_TYPE_XCCY_BASIS)) {
// Xccy basis swaps are not multiplied by a concentration com.acadiasoft.simm.model.risk factor (i.e. CR = 1 for Xccy)
return BigDecimal.ONE;
} else if (r.equals(RiskClass.INTEREST_RATE)) {
return ir.getDeltaConcentration(s.getQualifier(), all);
} else if (r.equals(RiskClass.FX)) {
return fx.getDeltaConcentration(s);
} else if (r.equals(RiskClass.EQUITY)) {
return eq.getDeltaConcentration(s);
} else if (r.equals(RiskClass.COMMODITY)) {
return cm.getDeltaConcentration(s);
} else if (r.equals(RiskClass.CREDIT_QUALIFYING)) {
return cq.getDeltaConcentration(s.getQualifier(), s.getBucket(), all);
} else if (r.equals(RiskClass.CREDIT_NON_QUALIFYING)) {
return cnq.getDeltaConcentration(s.getQualifier(), s.getBucket(), all);
} else {
throw new RuntimeException("found unknown com.acadiasoft.simm.model.risk class: " + r);
}
}
示例2: getCoefficientPerLitreMultiply
public static BigDecimal getCoefficientPerLitreMultiply(Currency currency) {
checkPropertiesAreLoaded();
if (properties.containsKey(currency.getCurrencyCode())) {
String[] currencyStrings = properties.getProperty(currency.getCurrencyCode()).split(DELIMETER);
return BigDecimal.valueOf(Integer.valueOf(currencyStrings[COEFFICIENT_PER_LITRE_MULTIPLY]));
}
return BigDecimal.ONE;
}
示例3: equals_identical
@Test
public void equals_identical() {
final DataSourceFieldCompositeValue<BigDecimal> candidateMatchPair
= new DefaultDataSourceFieldCompositeValue<>(
new DefaultDataSourceFieldValue<>(rate, BigDecimal.ONE),
new DefaultDataSourceFieldValue<>(rate, BigDecimal.ONE)
);
candidateMatchPair.match(equalsMatchingStrategy);
assertThat(candidateMatchPair.getMatched(), is(true));
}
示例4: testMarketOrder
@Test
public void testMarketOrder() throws Exception, BinanceApiException {
if (canTrade) {
// Testing Buying BNB with BTC - using market price
BinanceOrderPlacement placement = new BinanceOrderPlacement(symbol, BinanceOrderSide.BUY);
placement.setType(BinanceOrderType.MARKET);
BigDecimal qty = BigDecimal.ONE; // so we want to buy exactly 1 BNB
if (qty.compareTo(BigDecimal.ZERO) > 0) {
placement.setQuantity(qty); // sell some our asset for 1 BTC each
log.info("Market Order Test = {}", binanceApi.testOrder(placement));
}
}
}
示例5: execute
@Override
public BigDecimal execute(IWorkExecutor executor) {
BigDecimal queryResult = query.execute(executor);
if (queryResult.compareTo(BigDecimal.ZERO) == 0) {
return BigDecimal.ONE;
} else {
return BigDecimal.ZERO;
}
}
示例6: getGamma
/**
* Reads the gammavalue form the stored map.
* If uncoveredRegions greater than {@link #getKMax()}, then the value for kMax is returned (see model writeup for explanation).
* @param uncoveredRegions the number of regions that are uncovered
* @return the gamma value for the number of uncovered regions
*/
public BigDecimal getGamma(int uncoveredRegions) {
if (uncoveredRegions > getKMax()) {
uncoveredRegions = getKMax();
} else if (uncoveredRegions == 0) {
return BigDecimal.ONE;
}
return gammaValues.get(uncoveredRegions);
}
示例7: setUp
@Before
public void setUp() {
Semester localSemester = new Semester(2016, SemesterType.WinterSemester);
semester = semesterRepository.save(localSemester).toDto();
StudyPlan localStudyPlan = new StudyPlan("TestStudyPlan",
new EctsDistribution(BigDecimal.ONE, BigDecimal.ONE, BigDecimal.ONE));
studyPlan = studyPlanRepository.save(localStudyPlan);
}
示例8: computeFactorialAsBigDecimal
/**
* Computes the factorial for a given number and returns the result as a
* BigDecimal.
*
* @param n The number to calculate the factorial for.
* @return The result as a BigDecimal.
*/
public static BigDecimal computeFactorialAsBigDecimal(int n) {
BigDecimal val = BigDecimal.ONE;
for (Integer i = 0; i < n; i++) {
val = val.multiply(new BigDecimal(i + 1));
}
return val;
}
示例9: testBigDecimal
@Test
public void testBigDecimal() throws Exception {
BigDecimal v1 = BigDecimal.valueOf(Double.MIN_VALUE);
BigDecimal v2 = BigDecimal.valueOf(Double.MAX_VALUE).multiply(BigDecimal.valueOf(2));
BigDecimal v3 = BigDecimal.ZERO;
BigDecimal v4 = BigDecimal.ONE;
BigDecimal v5 = BigDecimal.TEN;
BigDecimal v6 = new BigDecimal(100);
BigDecimal v7 = new BigDecimal(BigInteger.valueOf(Long.MAX_VALUE).multiply(BigInteger.valueOf(2)));
check(input(v1, v2, v3, v4, v5, v6, v7), (v, out) -> out.writeBigDecimal(v), DataReader::readBigDecimal);
}
示例10: apply
public Number apply(ConnectionProperty connectionProperty, String s) {
if (s == null) {
throw new RuntimeException("Required property '"
+ connectionProperty.camelName() + "' not specified");
}
BigDecimal multiplier = BigDecimal.ONE;
for (Map.Entry<String, BigDecimal> e : MULTIPLIER_MAP.entrySet()) {
if (s.endsWith(e.getKey())) {
multiplier = e.getValue();
s = s.substring(0, s.length() - e.getKey().length());
}
}
return new BigDecimal(s).multiply(multiplier);
}
示例11: createDataTypesRows
protected void createDataTypesRows(RowSet crs) throws SQLException {
Integer aInteger = 100;
String aChar = "Oswald Cobblepot";
Long aLong = Long.MAX_VALUE;
Short aShort = Short.MAX_VALUE;
Double aDouble = Double.MAX_VALUE;
BigDecimal aBigDecimal = BigDecimal.ONE;
Boolean aBoolean = false;
Float aFloat = Float.MAX_VALUE;
Byte aByte = Byte.MAX_VALUE;
Date aDate = Date.valueOf(LocalDate.now());
Time aTime = Time.valueOf(LocalTime.now());
Timestamp aTimeStamp = Timestamp.valueOf(LocalDateTime.now());
Array aArray = new StubArray("INTEGER", new Object[1]);
Ref aRef = new SerialRef(new StubRef("INTEGER", query));
byte[] bytes = new byte[10];
crs.moveToInsertRow();
crs.updateInt(1, aInteger);
crs.updateString(2, aChar);
crs.updateString(3, aChar);
crs.updateLong(4, aLong);
crs.updateBoolean(5, aBoolean);
crs.updateShort(6, aShort);
crs.updateDouble(7, aDouble);
crs.updateBigDecimal(8, aBigDecimal);
crs.updateFloat(9, aFloat);
crs.updateByte(10, aByte);
crs.updateDate(11, aDate);
crs.updateTime(12, aTime);
crs.updateTimestamp(13, aTimeStamp);
crs.updateBytes(14, bytes);
crs.updateArray(15, aArray);
crs.updateRef(16, aRef);
crs.updateDouble(17, aDouble);
crs.insertRow();
crs.moveToCurrentRow();
}
示例12: testValidate
@Test
public void testValidate() {
String name = "1";
String password = "2";
String repeatedPassword = "3";
String email = "4";
BigDecimal goalInKg = BigDecimal.ONE;
NewUserDTO dto = NewUserDTO.of(name, password, repeatedPassword, email, goalInKg);
validator.validate(dto, errors);
verify(utils).validateName(name, errors);
verify(utils).validateEmail(email, null, errors);
verify(utils).validatePasswords(password, repeatedPassword, errors);
verify(utils).validateGoalInKg(goalInKg, errors);
}
示例13: getConditionalRiskWeight
public static BigDecimal getConditionalRiskWeight(RiskClass riskClass, Sensitivity sensitivity) {
if (riskClass.equals(RiskClass.EQUITY) || riskClass.equals(RiskClass.FX) || riskClass.equals(RiskClass.COMMODITY)) {
return RiskWeight.getRiskWeight(riskClass, sensitivity);
} else if (riskClass.equals(RiskClass.INTEREST_RATE) || riskClass.equals(RiskClass.CREDIT_QUALIFYING) || riskClass.equals(RiskClass.CREDIT_NON_QUALIFYING)) {
return BigDecimal.ONE;
} else {
throw new RuntimeException("Unsupported com.acadiasoft.simm.model.risk class detected:" + riskClass);
}
}
示例14: testGetStepCost_3
@Test
public void testGetStepCost_3() {
Long[] limitArray = { L1, L2, L3, L4, L5, null };
BigDecimal[] priceArray = { BD10, BD9, BD8, BD7, BD6, BD5 };
Long[] freeEntityCountArray = { L0, L1, L2, L3, L4, L5 };
BigDecimal[] additionalPriceArray = { BigDecimal.ZERO, BD10,
BigDecimal.valueOf(19), BigDecimal.valueOf(27),
BigDecimal.valueOf(34), BigDecimal.valueOf(40) };
List<SteppedPriceData> steppedPricesList = getSteppedPricesList(
limitArray, priceArray, freeEntityCountArray,
additionalPriceArray);
SteppedPriceDetail steppedpriceDetail = initSteppedPriceDetail(steppedPricesList);
BigDecimal value = new BigDecimal(10);
SteppedPriceDetail stepCost = calculator.calculateStepCost(
steppedpriceDetail, value);
BigDecimal actualCost = stepCost.getNormalizedCost();
checkEquals(new BigDecimal(65), actualCost, Numbers.BIGDECIMAL_SCALE);
List<SteppedPriceData> priceData = stepCost.getPriceData();
BigDecimal[] entityCount = { BigDecimal.ONE, BigDecimal.ONE,
BigDecimal.ONE, BigDecimal.ONE, BigDecimal.ONE, BD5 };
BigDecimal[] stepAmount = { BD10, BD9, BD8, BD7, BD6,
BigDecimal.valueOf(25) };
for (int i = 0; i < limitArray.length; i++) {
SteppedPriceData data = priceData.get(i);
checkEquals(additionalPriceArray[i], data.getAdditionalPrice(),
Numbers.BIGDECIMAL_SCALE);
Long limit = data.getLimit();
assertEquals(limitArray[i], limit);
assertEquals(freeEntityCountArray[i].longValue(),
data.getFreeEntityCount());
checkEquals(stepAmount[i], data.getStepAmount(),
Numbers.BIGDECIMAL_SCALE);
checkEquals(priceArray[i], data.getBasePrice(),
Numbers.BIGDECIMAL_SCALE);
checkEquals(entityCount[i], data.getStepEntityCount(),
Numbers.BIGDECIMAL_SCALE);
}
}
示例15: testBaseParameters
@DataProvider(name = "testBaseParameters")
private Object[][] testBaseParameters() throws SQLException {
Integer aInt = 1;
Long aLong = Long.MAX_VALUE;
Short aShort = Short.MIN_VALUE;
BigDecimal bd = BigDecimal.ONE;
Double aDouble = Double.MAX_VALUE;
Date aDate = Date.valueOf(LocalDate.now());
Time aTime = Time.valueOf(LocalTime.now());
Timestamp aTimeStamp = Timestamp.valueOf(LocalDateTime.now());
Calendar cal = Calendar.getInstance();
Boolean aBoolean = true;
Float aFloat = 1.5f;
Byte aByte = 1;
brs = new StubBaseRowSet();
brs.setInt(1, aInt);
brs.setString(2, query);
brs.setLong(3, aLong);
brs.setBoolean(4, aBoolean);
brs.setShort(5, aShort);
brs.setDouble(6, aDouble);
brs.setBigDecimal(7, bd);
brs.setFloat(8, aFloat);
brs.setByte(9, aByte);
brs.setDate(10, aDate);
brs.setTime(11, aTime);
brs.setTimestamp(12, aTimeStamp);
brs.setDate(13, aDate, cal);
brs.setTime(14, aTime, cal);
brs.setTimestamp(15, aTimeStamp);
brs.setObject(16, query);
brs.setObject(17, query, Types.CHAR);
brs.setObject(18, query, Types.CHAR, 0);
return new Object[][]{
{1, aInt},
{2, query},
{3, aLong},
{4, aBoolean},
{5, aShort},
{6, aDouble},
{7, bd},
{8, aFloat},
{9, aByte},
{10, aDate},
{11, aTime},
{12, aTimeStamp},
{13, aDate},
{14, aTime},
{15, aTimeStamp},
{16, query},
{17, query},
{18, query}
};
}