Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Data classes 13 public class User { private String userName; private String firstName; private String lastName; private Point location; public User(String userName, String firstName, String lastName) { this(userName,firstName, lastName, null); } public User(String userName, String firstName, String lastName, Point location) { Assert.notNull(userName); Assert.notNull(firstName); Assert.notNull(lastName); this.userName = userName; this.firstName = firstName; this.lastName = lastName; this.location = location; } public String getUserName() { return userName; } public void setUserName(String userName) { this.userName = userName; } 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 Point getLocation() { return location; } public void setLocation(Point location) { this.location = location; } @Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } UserJ j = (UserJ) o; if (!userName.equals(j.userName)) { return false; } if (!firstName.equals(j.firstName)) { return false; } if (!lastName.equals(j.lastName)) { return false; } return location != null ? location.equals(j.location) : j.location == null; } @Override public int hashCode() { int result = userName.hashCode(); result = 31 * result + firstName.hashCode(); result = 31 * result + lastName.hashCode(); result = 31 * result + (location != null ? location.hashCode() : 0); return result; } @Override public String toString() { return "User{" + "userName='" + userName + '\'' + ", firstName='" + firstName + '\'' + ", lastName='" + lastName + '\'' + ", location=" + location + '}'; } } data class User(
var userName: String,
var firstName: String,
var lastName: String,
var location: Point? = null
)