|
| 1 | +/* |
| 2 | + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with |
| 3 | + * the License. You may obtain a copy of the License at |
| 4 | + * |
| 5 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 6 | + * |
| 7 | + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on |
| 8 | + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the |
| 9 | + * specific language governing permissions and limitations under the License. |
| 10 | + * |
| 11 | + * Copyright 2012-2020 the original author or authors. |
| 12 | + */ |
| 13 | + |
| 14 | +package com.github.meixuesong.aggregatepersistence.complex_object; |
| 15 | + |
| 16 | +import com.github.meixuesong.aggregatepersistence.Versionable; |
| 17 | + |
| 18 | +import java.io.Serializable; |
| 19 | +import java.math.BigDecimal; |
| 20 | +import java.time.LocalDate; |
| 21 | +import java.time.LocalDateTime; |
| 22 | + |
| 23 | +public class Contract implements Versionable, Serializable { |
| 24 | + private String id; |
| 25 | + private LoanCustomer customer; |
| 26 | + private BigDecimal interestRate; |
| 27 | + private RepaymentType repaymentType; |
| 28 | + private LocalDate maturityDate; |
| 29 | + private BigDecimal commitment; |
| 30 | + private LocalDateTime createdAt; |
| 31 | + private ContractStatus status; |
| 32 | + private int version; |
| 33 | + |
| 34 | + |
| 35 | + Contract(String id, LoanCustomer customer, BigDecimal interestRate, RepaymentType repaymentType, LocalDate maturityDate, BigDecimal commitment, LocalDateTime createdAt, ContractStatus status) { |
| 36 | + this.id = id; |
| 37 | + this.customer = customer; |
| 38 | + this.interestRate = interestRate; |
| 39 | + this.repaymentType = repaymentType; |
| 40 | + this.maturityDate = maturityDate; |
| 41 | + this.commitment = commitment; |
| 42 | + this.createdAt = createdAt; |
| 43 | + this.status = status; |
| 44 | + } |
| 45 | + |
| 46 | + public String getId() { |
| 47 | + return id; |
| 48 | + } |
| 49 | + |
| 50 | + public LoanCustomer getCustomer() { |
| 51 | + return customer; |
| 52 | + } |
| 53 | + |
| 54 | + public BigDecimal getInterestRate() { |
| 55 | + return interestRate; |
| 56 | + } |
| 57 | + |
| 58 | + public RepaymentType getRepaymentType() { |
| 59 | + return repaymentType; |
| 60 | + } |
| 61 | + |
| 62 | + public LocalDate getMaturityDate() { |
| 63 | + return maturityDate; |
| 64 | + } |
| 65 | + |
| 66 | + public BigDecimal getCommitment() { |
| 67 | + return commitment; |
| 68 | + } |
| 69 | + |
| 70 | + public LocalDateTime getCreatedAt() { |
| 71 | + return createdAt; |
| 72 | + } |
| 73 | + |
| 74 | + public ContractStatus getStatus() { |
| 75 | + return status; |
| 76 | + } |
| 77 | + |
| 78 | + public void setCommitment(BigDecimal commitment) { |
| 79 | + this.commitment = commitment; |
| 80 | + } |
| 81 | + |
| 82 | + @Override |
| 83 | + public int getVersion() { |
| 84 | + return 0; |
| 85 | + } |
| 86 | + |
| 87 | + public void setVersion(int version) { |
| 88 | + this.version = version; |
| 89 | + } |
| 90 | + |
| 91 | + @Override |
| 92 | + public boolean equals(Object o) { |
| 93 | + if (this == o) return true; |
| 94 | + if (o == null || getClass() != o.getClass()) return false; |
| 95 | + |
| 96 | + Contract contract = (Contract) o; |
| 97 | + |
| 98 | + if (version != contract.version) return false; |
| 99 | + if (!id.equals(contract.id)) return false; |
| 100 | + if (!customer.equals(contract.customer)) return false; |
| 101 | + if (!interestRate.equals(contract.interestRate)) return false; |
| 102 | + if (repaymentType != contract.repaymentType) return false; |
| 103 | + if (!maturityDate.equals(contract.maturityDate)) return false; |
| 104 | + if (!commitment.equals(contract.commitment)) return false; |
| 105 | + if (!createdAt.equals(contract.createdAt)) return false; |
| 106 | + return status == contract.status; |
| 107 | + } |
| 108 | + |
| 109 | + @Override |
| 110 | + public int hashCode() { |
| 111 | + int result = id.hashCode(); |
| 112 | + result = 31 * result + customer.hashCode(); |
| 113 | + result = 31 * result + interestRate.hashCode(); |
| 114 | + result = 31 * result + repaymentType.hashCode(); |
| 115 | + result = 31 * result + maturityDate.hashCode(); |
| 116 | + result = 31 * result + commitment.hashCode(); |
| 117 | + result = 31 * result + createdAt.hashCode(); |
| 118 | + result = 31 * result + status.hashCode(); |
| 119 | + result = 31 * result + version; |
| 120 | + return result; |
| 121 | + } |
| 122 | +} |
0 commit comments