Rev 35406 | Blame | Compare with Previous | Last modification | View Log | RSS feed
package com.spice.profitmandi.dao.entity.fofo;import com.spice.profitmandi.dao.convertor.LocalDateTimeAttributeConverter;import javax.persistence.*;import java.io.Serializable;import java.time.LocalDateTime;import java.util.List;/*** Entity representing Pinelabs customer mapping.* Maps internal customers (fofo.customer) to Pinelabs customer IDs for payment tokenization.** @author Pinelabs Integration Team* @since 1.0*/@Entity@Table(name = "fofo.pinelabs_customers", schema = "fofo")public class PinelabsCustomer implements Serializable {private static final long serialVersionUID = 1L;@Id@Column(name = "id")@GeneratedValue(strategy = GenerationType.IDENTITY)private Long id;/*** Reference to internal customer ID (fofo.customer.id)*/@Column(name = "customer_id", nullable = false, unique = true)private Integer customerId;/*** Customer ID generated by Pinelabs API*/@Column(name = "pinelabs_customer_id", nullable = false, unique = true, length = 100)private String pinelabsCustomerId;/*** Customer mobile number (mirror from customer table for sync)*/@Column(name = "mobile_number", length = 20)private String mobileNumber;/*** Customer email (mirror from customer table for sync)*/@Column(name = "email", length = 255)private String email;/*** Customer first name*/@Column(name = "first_name", length = 100)private String firstName;/*** Customer last name*/@Column(name = "last_name", length = 100)private String lastName;/*** Record creation timestamp*/@Convert(converter = LocalDateTimeAttributeConverter.class)@Column(name = "create_timestamp", nullable = false, updatable = false)private LocalDateTime createTimestamp = LocalDateTime.now();/*** Record last update timestamp*/@Convert(converter = LocalDateTimeAttributeConverter.class)@Column(name = "update_timestamp", nullable = false)private LocalDateTime updateTimestamp = LocalDateTime.now();/*** Saved payment methods for this customer*/@OneToMany(mappedBy = "pinelabsCustomer", cascade = CascadeType.ALL, fetch = FetchType.LAZY)private List<PinelabsPaymentMethod> paymentMethods;/*** Default constructor*/public PinelabsCustomer() {}/*** Constructor with customer ID** @param customerId Internal customer ID*/public PinelabsCustomer(Integer customerId) {this.customerId = customerId;}// ==================== Getters and Setters ====================public Long getId() {return id;}public void setId(Long id) {this.id = id;}public Integer getCustomerId() {return customerId;}public void setCustomerId(Integer customerId) {this.customerId = customerId;}public String getPinelabsCustomerId() {return pinelabsCustomerId;}public void setPinelabsCustomerId(String pinelabsCustomerId) {this.pinelabsCustomerId = pinelabsCustomerId;}public String getMobileNumber() {return mobileNumber;}public void setMobileNumber(String mobileNumber) {this.mobileNumber = mobileNumber;}public String getEmail() {return email;}public void setEmail(String email) {this.email = email;}public String getFirstName() {return firstName;}public void setFirstName(String firstName) {this.firstName = firstName;}public String getLastName() {return lastName;}public void setLastName(String lastName) {this.lastName = lastName;}public LocalDateTime getCreateTimestamp() {return createTimestamp;}public void setCreateTimestamp(LocalDateTime createTimestamp) {this.createTimestamp = createTimestamp;}public LocalDateTime getUpdateTimestamp() {return updateTimestamp;}public void setUpdateTimestamp(LocalDateTime updateTimestamp) {this.updateTimestamp = updateTimestamp;}public List<PinelabsPaymentMethod> getPaymentMethods() {return paymentMethods;}public void setPaymentMethods(List<PinelabsPaymentMethod> paymentMethods) {this.paymentMethods = paymentMethods;}// ==================== Helper Methods ====================/*** Get full name of customer** @return Full name (firstName + lastName)*/public String getFullName() {if (firstName == null && lastName == null) {return null;}StringBuilder fullName = new StringBuilder();if (firstName != null) {fullName.append(firstName);}if (lastName != null) {if (fullName.length() > 0) {fullName.append(" ");}fullName.append(lastName);}return fullName.toString();}// ==================== Object Methods ====================@Overridepublic int hashCode() {final int prime = 31;int result = 1;result = prime * result + ((id == null) ? 0 : id.hashCode());result = prime * result + ((customerId == null) ? 0 : customerId.hashCode());result = prime * result + ((pinelabsCustomerId == null) ? 0 : pinelabsCustomerId.hashCode());return result;}@Overridepublic boolean equals(Object obj) {if (this == obj)return true;if (obj == null)return false;if (getClass() != obj.getClass())return false;PinelabsCustomer other = (PinelabsCustomer) obj;if (id == null) {if (other.id != null)return false;} else if (!id.equals(other.id))return false;if (customerId == null) {if (other.customerId != null)return false;} else if (!customerId.equals(other.customerId))return false;if (pinelabsCustomerId == null) {if (other.pinelabsCustomerId != null)return false;} else if (!pinelabsCustomerId.equals(other.pinelabsCustomerId))return false;return true;}@Overridepublic String toString() {return "PinelabsCustomer [id=" + id + ", customerId=" + customerId + ", pinelabsCustomerId="+ pinelabsCustomerId + ", mobileNumber=" + mobileNumber + ", email=" + email + ", firstName="+ firstName + ", lastName=" + lastName + ", createTimestamp=" + createTimestamp+ ", updateTimestamp=" + updateTimestamp + "]";}}