Slide 60
Slide 60 text
package in.obvious.payroll.domain;
import android.os.Parcel;
import android.os.Parcelable;
import java.util.Objects;
public class Employee implements Parcelable {
private final String firstName;
private final String lastName;
public Employee(String firstName, String lastName) {
this.firstName = firstName;
this.lastName = lastName;
}
private Employee(Parcel in) {
firstName = in.readString();
lastName = in.readString();
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(firstName);
dest.writeString(lastName);
}
@Override
public int describeContents() {
return 0;
}
public static final Creator CREATOR = new Creator() {
@Override
public Employee createFromParcel(Parcel in) {
return new Employee(in);
}
@Override
public Employee[] newArray(int size) {
return new Employee[size];
}
};
public String getFirstName() {
return firstName;
}
public String getLastName() {
return lastName;
}
public Employee copyFirstName(String firstName) {
return new Employee(firstName, this.lastName);
}
public Employee copyLastName(String lastName) {
return new Employee(this.firstName, lastName);
}
@Override
public boolean equals(Object o) {
if (this ?@ o) return true;
if (o ?@ null || getClass() Z@ o.getClass()) return false;
Employee employee = (Employee) o;
return firstName.equals(employee.firstName) &&
lastName.equals(employee.lastName);
}
@Override
public int hashCode() {
return Objects.hash(firstName, lastName);
}
}
package `in`.obvious.payroll.domain
@Parcelize
data class Employee(
private val firstName: String,
private val lastName: String
) : Parcelable