The model

The Invoice total_model class contains all technical attributes that are either evaluated or calculated by the decision table, such as e.g. purchase order value, discount or shipping costs.

Manually programmed
We like using Lombok – it saves the manual programming of all standard glue codes, such as e.g. constructors and access methods.
Manually programmed Java class:
package lfet.demo;
import lombok.Data;
import java.math.BigDecimal;
@Data
public class InvoiceTotal_model {
private final BigDecimal orderValue;
private final BigDecimal orderDiscount;
private final String discountType; // "%", "EUR"
private final BigDecimal postage;
private BigDecimal totalPostage = BigDecimal.ZERO;
private BigDecimal totalDiscount = BigDecimal.ZERO;
private BigDecimal totalAmount = BigDecimal.ZERO;
public boolean isDiscountPercent() {
return discountType.contains("%");
}
}
Created by Lombok
This section is only addressed to those who do not know Lombok yet.
The java class created automatically by Lombok:
package lfet.demo;
import java.math.BigDecimal;
import lombok.Generated;
public class InvoiceTotal_model {
private final BigDecimal orderValue;
private final BigDecimal orderDiscount;
private final String discountType;
private final BigDecimal postage;
private BigDecimal totalPostage;
private BigDecimal totalDiscount;
private BigDecimal totalAmount;
public boolean isDiscountPercent() {
return this.discountType.contains("%");
}
@Generated
public InvoiceTotal_model(BigDecimal orderValue, BigDecimal orderDiscount, String discountType, BigDecimal postage) {
this.totalPostage = BigDecimal.ZERO;
this.totalDiscount = BigDecimal.ZERO;
this.totalAmount = BigDecimal.ZERO;
this.orderValue = orderValue;
this.orderDiscount = orderDiscount;
this.discountType = discountType;
this.postage = postage;
}
@Generated
public BigDecimal getOrderValue() {
return this.orderValue;
}
@Generated
public BigDecimal getOrderDiscount() {
return this.orderDiscount;
}
@Generated
public String getDiscountType() {
return this.discountType;
}
@Generated
public BigDecimal getPostage() {
return this.postage;
}
@Generated
public BigDecimal getTotalPostage() {
return this.totalPostage;
}
@Generated
public BigDecimal getTotalDiscount() {
return this.totalDiscount;
}
@Generated
public BigDecimal getTotalAmount() {
return this.totalAmount;
}
@Generated
public void setTotalPostage(BigDecimal totalPostage) {
this.totalPostage = totalPostage;
}
@Generated
public void setTotalDiscount(BigDecimal totalDiscount) {
this.totalDiscount = totalDiscount;
}
@Generated
public void setTotalAmount(BigDecimal totalAmount) {
this.totalAmount = totalAmount;
}
@Generated
public boolean equals(Object o) {
if (o == this) {
return true;
} else if (!(o instanceof InvoiceTotal_model)) {
return false;
} else {
InvoiceTotal_model other = (InvoiceTotal_model)o;
if (!other.canEqual(this)) {
return false;
} else {
Object this$orderValue = this.getOrderValue();
Object other$orderValue = other.getOrderValue();
if (this$orderValue == null) {
if (other$orderValue != null) {
return false;
}
} else if (!this$orderValue.equals(other$orderValue)) {
return false;
}
Object this$orderDiscount = this.getOrderDiscount();
Object other$orderDiscount = other.getOrderDiscount();
if (this$orderDiscount == null) {
if (other$orderDiscount != null) {
return false;
}
} else if (!this$orderDiscount.equals(other$orderDiscount)) {
return false;
}
Object this$discountType = this.getDiscountType();
Object other$discountType = other.getDiscountType();
if (this$discountType == null) {
if (other$discountType != null) {
return false;
}
} else if (!this$discountType.equals(other$discountType)) {
return false;
}
Object this$postage = this.getPostage();
Object other$postage = other.getPostage();
if (this$postage == null) {
if (other$postage != null) {
return false;
}
} else if (!this$postage.equals(other$postage)) {
return false;
}
Object this$totalPostage = this.getTotalPostage();
Object other$totalPostage = other.getTotalPostage();
if (this$totalPostage == null) {
if (other$totalPostage != null) {
return false;
}
} else if (!this$totalPostage.equals(other$totalPostage)) {
return false;
}
Object this$totalDiscount = this.getTotalDiscount();
Object other$totalDiscount = other.getTotalDiscount();
if (this$totalDiscount == null) {
if (other$totalDiscount != null) {
return false;
}
} else if (!this$totalDiscount.equals(other$totalDiscount)) {
return false;
}
Object this$totalAmount = this.getTotalAmount();
Object other$totalAmount = other.getTotalAmount();
if (this$totalAmount == null) {
if (other$totalAmount != null) {
return false;
}
} else if (!this$totalAmount.equals(other$totalAmount)) {
return false;
}
return true;
}
}
}
@Generated
protected boolean canEqual(Object other) {
return other instanceof InvoiceTotal_model;
}
@Generated
public int hashCode() {
int PRIME = 59;
int result = 1;
Object $orderValue = this.getOrderValue();
result = result * 59 + ($orderValue == null ? 43 : $orderValue.hashCode());
Object $orderDiscount = this.getOrderDiscount();
result = result * 59 + ($orderDiscount == null ? 43 : $orderDiscount.hashCode());
Object $discountType = this.getDiscountType();
result = result * 59 + ($discountType == null ? 43 : $discountType.hashCode());
Object $postage = this.getPostage();
result = result * 59 + ($postage == null ? 43 : $postage.hashCode());
Object $totalPostage = this.getTotalPostage();
result = result * 59 + ($totalPostage == null ? 43 : $totalPostage.hashCode());
Object $totalDiscount = this.getTotalDiscount();
result = result * 59 + ($totalDiscount == null ? 43 : $totalDiscount.hashCode());
Object $totalAmount = this.getTotalAmount();
result = result * 59 + ($totalAmount == null ? 43 : $totalAmount.hashCode());
return result;
}
@Generated
public String toString() {
String var10000 = String.valueOf(this.getOrderValue());
return "InvoiceTotal_model(orderValue=" + var10000
+ ", orderDiscount=" + String.valueOf(this.getOrderDiscount())
+ ", discountType=" + this.getDiscountType()
+ ", postage=" + String.valueOf(this.getPostage())
+ ", totalPostage=" + String.valueOf(this.getTotalPostage())
+ ", totalDiscount=" + String.valueOf(this.getTotalDiscount())
+ ", totalAmount=" + String.valueOf(this.getTotalAmount()) + ")";
}
}