supress warnings on data fields.

This commit is contained in:
Keith Woodlock
2013-10-18 01:18:33 +01:00
parent e1c2d36d10
commit 5cba17bba0
2 changed files with 45 additions and 44 deletions
@@ -81,7 +81,6 @@ public class Charge extends AbstractPersistable<Long> {
@Column(name = "max_cap", scale = 6, precision = 19, nullable = true) @Column(name = "max_cap", scale = 6, precision = 19, nullable = true)
private BigDecimal maxCap; private BigDecimal maxCap;
public static Charge fromJson(final JsonCommand command) { public static Charge fromJson(final JsonCommand command) {
final String name = command.stringValueOfParameterNamed("name"); final String name = command.stringValueOfParameterNamed("name");
@@ -94,7 +93,7 @@ public class Charge extends AbstractPersistable<Long> {
.integerValueOfParameterNamed("chargeCalculationType")); .integerValueOfParameterNamed("chargeCalculationType"));
final Integer chargePaymentMode = command.integerValueOfParameterNamed("chargePaymentMode"); final Integer chargePaymentMode = command.integerValueOfParameterNamed("chargePaymentMode");
final ChargePaymentMode paymentMode = (chargePaymentMode == null) ? null : ChargePaymentMode.fromInt(chargePaymentMode); final ChargePaymentMode paymentMode = chargePaymentMode == null ? null : ChargePaymentMode.fromInt(chargePaymentMode);
final boolean penalty = command.booleanPrimitiveValueOfParameterNamed("penalty"); final boolean penalty = command.booleanPrimitiveValueOfParameterNamed("penalty");
final boolean active = command.booleanPrimitiveValueOfParameterNamed("active"); final boolean active = command.booleanPrimitiveValueOfParameterNamed("active");
@@ -123,7 +122,7 @@ public class Charge extends AbstractPersistable<Long> {
this.chargeCalculation = chargeCalculationType.getValue(); this.chargeCalculation = chargeCalculationType.getValue();
this.penalty = penalty; this.penalty = penalty;
this.active = active; this.active = active;
this.chargePaymentMode = (paymentMode == null) ? null : paymentMode.getValue(); this.chargePaymentMode = paymentMode == null ? null : paymentMode.getValue();
this.minCap = minCap; this.minCap = minCap;
this.maxCap = maxCap; this.maxCap = maxCap;
@@ -148,7 +147,8 @@ public class Charge extends AbstractPersistable<Long> {
.failWithCodeNoParameterAddedToErrorCode("not.allowed.charge.calculation.type.for.savings"); .failWithCodeNoParameterAddedToErrorCode("not.allowed.charge.calculation.type.for.savings");
} }
if (!ChargeTimeType.fromInt(getChargeTime()).isWithdrawalFee() && ChargeCalculationType.fromInt(getChargeCalculation()).isPercentageOfAmount()) { if (!ChargeTimeType.fromInt(getChargeTime()).isWithdrawalFee()
&& ChargeCalculationType.fromInt(getChargeCalculation()).isPercentageOfAmount()) {
baseDataValidator.reset().parameter("chargeCalculationType").value(this.chargeCalculation) baseDataValidator.reset().parameter("chargeCalculationType").value(this.chargeCalculation)
.failWithCodeNoParameterAddedToErrorCode("savings.charge.calculation.type.percentage.allowed.only.for.withdrawal"); .failWithCodeNoParameterAddedToErrorCode("savings.charge.calculation.type.percentage.allowed.only.for.withdrawal");
} }
@@ -244,7 +244,6 @@ public class Charge extends AbstractPersistable<Long> {
return this.minCap; return this.minCap;
} }
public BigDecimal getMaxCap() { public BigDecimal getMaxCap() {
return this.maxCap; return this.maxCap;
} }
@@ -292,7 +291,8 @@ public class Charge extends AbstractPersistable<Long> {
baseDataValidator.reset().parameter("chargeTimeType").value(this.chargeTime) baseDataValidator.reset().parameter("chargeTimeType").value(this.chargeTime)
.failWithCodeNoParameterAddedToErrorCode("not.allowed.charge.time.for.savings"); .failWithCodeNoParameterAddedToErrorCode("not.allowed.charge.time.for.savings");
} }
//if charge time is changed to monthly then validate for feeOnMonthDay and feeInterval // if charge time is changed to monthly then validate for
// feeOnMonthDay and feeInterval
if (isMonthlyFee()) { if (isMonthlyFee()) {
final MonthDay monthDay = command.extractMonthDayNamed("feeOnMonthDay"); final MonthDay monthDay = command.extractMonthDayNamed("feeOnMonthDay");
baseDataValidator.reset().parameter("feeOnMonthDay").value(monthDay).notNull(); baseDataValidator.reset().parameter("feeOnMonthDay").value(monthDay).notNull();
@@ -336,14 +336,15 @@ public class Charge extends AbstractPersistable<Long> {
.failWithCodeNoParameterAddedToErrorCode("not.allowed.charge.calculation.type.for.savings"); .failWithCodeNoParameterAddedToErrorCode("not.allowed.charge.calculation.type.for.savings");
} }
if (!ChargeTimeType.fromInt(getChargeTime()).isWithdrawalFee() && ChargeCalculationType.fromInt(getChargeCalculation()).isPercentageOfAmount()) { if (!ChargeTimeType.fromInt(getChargeTime()).isWithdrawalFee()
&& ChargeCalculationType.fromInt(getChargeCalculation()).isPercentageOfAmount()) {
baseDataValidator.reset().parameter("chargeCalculationType").value(this.chargeCalculation) baseDataValidator.reset().parameter("chargeCalculationType").value(this.chargeCalculation)
.failWithCodeNoParameterAddedToErrorCode("charge.calculation.type.percentage.allowed.only.for.withdrawal"); .failWithCodeNoParameterAddedToErrorCode("charge.calculation.type.percentage.allowed.only.for.withdrawal");
} }
} }
} }
if (this.isLoanCharge()) {// validate only for loan charge if (isLoanCharge()) {// validate only for loan charge
final String paymentModeParamName = "chargePaymentMode"; final String paymentModeParamName = "chargePaymentMode";
if (command.isChangeInIntegerParameterNamed(paymentModeParamName, this.chargePaymentMode)) { if (command.isChangeInIntegerParameterNamed(paymentModeParamName, this.chargePaymentMode)) {
final Integer newValue = command.integerValueOfParameterNamed(paymentModeParamName); final Integer newValue = command.integerValueOfParameterNamed(paymentModeParamName);
@@ -410,8 +411,6 @@ public class Charge extends AbstractPersistable<Long> {
} }
} }
if (this.penalty && ChargeTimeType.fromInt(this.chargeTime).isTimeOfDisbursement()) { throw new ChargeDueAtDisbursementCannotBePenaltyException( if (this.penalty && ChargeTimeType.fromInt(this.chargeTime).isTimeOfDisbursement()) { throw new ChargeDueAtDisbursementCannotBePenaltyException(
this.name); } this.name); }
@@ -439,7 +438,7 @@ public class Charge extends AbstractPersistable<Long> {
final EnumOptionData chargePaymentmode = ChargeEnumerations.chargePaymentMode(this.chargePaymentMode); final EnumOptionData chargePaymentmode = ChargeEnumerations.chargePaymentMode(this.chargePaymentMode);
final CurrencyData currency = new CurrencyData(this.currencyCode, null, 0, 0, null, null); final CurrencyData currency = new CurrencyData(this.currencyCode, null, 0, 0, null, null);
return ChargeData.instance(getId(), this.name, this.amount, currency, chargeTimeType, chargeAppliesTo, chargeCalculationType, return ChargeData.instance(getId(), this.name, this.amount, currency, chargeTimeType, chargeAppliesTo, chargeCalculationType,
chargePaymentmode, this.getFeeOnMonthDay(), this.feeInterval, this.penalty, this.active,this.minCap,this.maxCap); chargePaymentmode, getFeeOnMonthDay(), this.feeInterval, this.penalty, this.active, this.minCap, this.maxCap);
} }
public Integer getChargePaymentMode() { public Integer getChargePaymentMode() {
@@ -456,8 +455,8 @@ public class Charge extends AbstractPersistable<Long> {
public MonthDay getFeeOnMonthDay() { public MonthDay getFeeOnMonthDay() {
MonthDay feeOnMonthDay = null; MonthDay feeOnMonthDay = null;
if (feeOnDay != null && feeOnMonth != null) { if (this.feeOnDay != null && this.feeOnMonth != null) {
feeOnMonthDay = new MonthDay(feeOnMonth, feeOnDay); feeOnMonthDay = new MonthDay(this.feeOnMonth, this.feeOnDay);
} }
return feeOnMonthDay; return feeOnMonthDay;
} }
@@ -72,12 +72,15 @@ public class LoanChargeData {
private final Long loanId; private final Long loanId;
@SuppressWarnings("unused")
private final BigDecimal minCap; private final BigDecimal minCap;
@SuppressWarnings("unused")
private final BigDecimal maxCap; private final BigDecimal maxCap;
public static LoanChargeData template(final Collection<ChargeData> chargeOptions) { public static LoanChargeData template(final Collection<ChargeData> chargeOptions) {
return new LoanChargeData(null, null, null, null, null, null, null, null, chargeOptions, false, null, false, false, null,null,null); return new LoanChargeData(null, null, null, null, null, null, null, null, chargeOptions, false, null, false, false, null, null,
null);
} }
/** /**
@@ -86,7 +89,8 @@ public class LoanChargeData {
*/ */
public static LoanChargeData newLoanChargeDetails(final Long chargeId, final String name, final CurrencyData currency, public static LoanChargeData newLoanChargeDetails(final Long chargeId, final String name, final CurrencyData currency,
final BigDecimal amount, final BigDecimal percentage, final EnumOptionData chargeTimeType, final BigDecimal amount, final BigDecimal percentage, final EnumOptionData chargeTimeType,
final EnumOptionData chargeCalculationType, final boolean penalty, final EnumOptionData chargePaymentMode,final BigDecimal minCap,final BigDecimal maxCap) { final EnumOptionData chargeCalculationType, final boolean penalty, final EnumOptionData chargePaymentMode,
final BigDecimal minCap, final BigDecimal maxCap) {
return new LoanChargeData(null, chargeId, name, currency, amount, percentage, chargeTimeType, chargeCalculationType, null, penalty, return new LoanChargeData(null, chargeId, name, currency, amount, percentage, chargeTimeType, chargeCalculationType, null, penalty,
chargePaymentMode, false, false, null, minCap, maxCap); chargePaymentMode, false, false, null, minCap, maxCap);
} }
@@ -152,8 +156,6 @@ public class LoanChargeData {
this.paid = paid; this.paid = paid;
this.waived = waived; this.waived = waived;
if (chargeCalculationType != null && chargeCalculationType.getId().intValue() > 1) { if (chargeCalculationType != null && chargeCalculationType.getId().intValue() > 1) {
this.amountOrPercentage = this.percentage; this.amountOrPercentage = this.percentage;
} else { } else {