Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Customer {
- private String name;
- private String email;
- private String company;
- public Customer(String name) {
- this(name, "", "");
- }
- public Customer(String name, String email) {
- this(name, email, "");
- }
- public Customer(String name, String email, String company) {
- this.name = name;
- this.email = email;
- this.company = company;
- }
- public String getName() {
- return name;
- }
- public void setName(String name) {
- this.name = name;
- }
- public String getEmail() {
- return email;
- }
- public void setEmail(String email) {
- this.email = email;
- }
- public String getCompany() {
- return company;
- }
- public void setCompany(String company) {
- this.company = company;
- }
- @Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
- Customer customer = (Customer) o;
- if (name != null ? !name.equals(customer.name) : customer.name != null) return false;
- if (email != null ? !email.equals(customer.email) : customer.email != null) return false;
- return company != null ? company.equals(customer.company) : customer.company == null;
- }
- @Override
- public int hashCode() {
- int result = name != null ? name.hashCode() : 0;
- result = 31 * result + (email != null ? email.hashCode() : 0);
- result = 31 * result + (company != null ? company.hashCode() : 0);
- return result;
- }
- @Override
- public String toString() {
- return "Customer{" +
- "name='" + name + '\'' +
- ", email='" + email + '\'' +
- ", company='" + company + '\'' +
- '}';
- }
- }
- /*
- Kotlin alternative
- data class Customer(var name: String, var email: String = "",
- var company: String = "")
- */
Add Comment
Please, Sign In to add comment