📄 payment.java
字号:
/*
* Copyright 2006 Borys Burnayev
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.rdacorp.petstore.domain;
import java.math.BigDecimal;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Version;
/**
* @author Borys Burnayev
*/
@Entity
@Table(name = "payment")
@SequenceGenerator(name = "PaymentSeq", sequenceName = "sq_payment")
public class Payment {
private Integer paymentId;
private BigDecimal amount;
private Date paymentTs;
private String creditCardNumber;
private int expirationMonth;
private int expirationYear;
private CreditCardCompany creditCardCompany;
private Account account;
private Order order;
private int version;
@Column(name = "row_version")
@Version
public int getVersion() {
return version;
}
public void setVersion(int version) {
this.version = version;
}
public Payment(BigDecimal amount, Date paymentTs, String creditCardNumber, int expirationMonth, int expirationYear,
CreditCardCompany creditCardCompany, Account account) {
this.amount = amount;
this.paymentTs = paymentTs;
this.creditCardNumber = creditCardNumber;
this.expirationMonth = expirationMonth;
this.expirationYear = expirationYear;
this.creditCardCompany = creditCardCompany;
this.account = account;
}
public Payment() {
}
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "PaymentSeq")
@Column(name = "payment_sysid")
public Integer getPaymentId() {
return this.paymentId;
}
public void setPaymentId(Integer paymentId) {
this.paymentId = paymentId;
}
@Column(name = "amount")
public BigDecimal getAmount() {
return this.amount;
}
public void setAmount(BigDecimal amount) {
this.amount = amount;
}
@Column(name = "payment_ts")
public Date getPaymentTs() {
return this.paymentTs;
}
public void setPaymentTs(Date paymentTs) {
this.paymentTs = paymentTs;
}
@Column(name = "credit_card_number")
public String getCreditCardNumber() {
return this.creditCardNumber;
}
public void setCreditCardNumber(String creditCardNumber) {
this.creditCardNumber = creditCardNumber;
}
@Column(name = "expiration_month")
public int getExpirationMonth() {
return this.expirationMonth;
}
public void setExpirationMonth(int expirationMonth) {
this.expirationMonth = expirationMonth;
}
@Column(name = "expiration_year")
public int getExpirationYear() {
return this.expirationYear;
}
public void setExpirationYear(int expirationYear) {
this.expirationYear = expirationYear;
}
@ManyToOne
@JoinColumn(name = "credit_card_company_sysid", referencedColumnName = "credit_card_company_sysid")
public CreditCardCompany getCreditCardCompany() {
return this.creditCardCompany;
}
public void setCreditCardCompany(CreditCardCompany creditCardCompany) {
this.creditCardCompany = creditCardCompany;
}
@ManyToOne
@JoinColumn(name = "account_sysid")
public Account getAccount() {
return this.account;
}
public void setAccount(Account account) {
this.account = account;
}
@OneToOne(mappedBy = "payment")
public Order getOrder() {
return order;
}
public void setOrder(Order order) {
this.order = order;
}
public String toString() {
String id = paymentId != null ? paymentId.toString() : "<no ID>";
return "Payment " + id + ":\nAmount: " + amount + "\nCredit Card Number: " + creditCardNumber
+ "\nExpiration Month: " + expirationMonth + "\nExpiration Year: " + expirationYear
+ "\nPayment Timestamp: " + paymentTs + "\n" + account + creditCardCompany;
}
public boolean equals(Object object) {
if (!(object instanceof Payment))
return false;
Payment payment = (Payment) object;
return amount.equals(payment.getAmount()) && creditCardNumber.equals(payment.getCreditCardNumber())
&& expirationMonth == payment.expirationMonth && expirationYear == payment.expirationYear
&& account.equals(payment.account) && creditCardCompany.equals(payment.creditCardCompany);
}
public int hashCode() {
return amount.hashCode();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -