com.company.sakila.db0.sakila.rental.generated.GeneratedRentalImpl Maven / Gradle / Ivy
package com.company.sakila.db0.sakila.rental.generated;
import com.company.sakila.db0.sakila.customer.Customer;
import com.company.sakila.db0.sakila.inventory.Inventory;
import com.company.sakila.db0.sakila.rental.Rental;
import com.company.sakila.db0.sakila.staff.Staff;
import com.speedment.common.annotation.GeneratedCode;
import com.speedment.runtime.core.manager.Manager;
import com.speedment.runtime.core.util.OptionalUtil;
import java.sql.Timestamp;
import java.util.Objects;
import java.util.Optional;
import java.util.StringJoiner;
/**
* The generated base implementation of the {@link
* com.company.sakila.db0.sakila.rental.Rental}-interface.
*
* This file has been automatically generated by Speedment. Any changes made to
* it will be overwritten.
*
* @author Speedment
*/
@GeneratedCode("Speedment")
public abstract class GeneratedRentalImpl implements Rental {
private int rentalId;
private Timestamp rentalDate;
private int inventoryId;
private int customerId;
private Timestamp returnDate;
private short staffId;
private Timestamp lastUpdate;
protected GeneratedRentalImpl() {
}
@Override
public int getRentalId() {
return rentalId;
}
@Override
public Timestamp getRentalDate() {
return rentalDate;
}
@Override
public int getInventoryId() {
return inventoryId;
}
@Override
public int getCustomerId() {
return customerId;
}
@Override
public Optional getReturnDate() {
return Optional.ofNullable(returnDate);
}
@Override
public short getStaffId() {
return staffId;
}
@Override
public Timestamp getLastUpdate() {
return lastUpdate;
}
@Override
public Rental setRentalId(int rentalId) {
this.rentalId = rentalId;
return this;
}
@Override
public Rental setRentalDate(Timestamp rentalDate) {
this.rentalDate = rentalDate;
return this;
}
@Override
public Rental setInventoryId(int inventoryId) {
this.inventoryId = inventoryId;
return this;
}
@Override
public Rental setCustomerId(int customerId) {
this.customerId = customerId;
return this;
}
@Override
public Rental setReturnDate(Timestamp returnDate) {
this.returnDate = returnDate;
return this;
}
@Override
public Rental setStaffId(short staffId) {
this.staffId = staffId;
return this;
}
@Override
public Rental setLastUpdate(Timestamp lastUpdate) {
this.lastUpdate = lastUpdate;
return this;
}
@Override
public Inventory findInventoryId(Manager foreignManager) {
return foreignManager.stream().filter(Inventory.INVENTORY_ID.equal(getInventoryId())).findAny().orElse(null);
}
@Override
public Customer findCustomerId(Manager foreignManager) {
return foreignManager.stream().filter(Customer.CUSTOMER_ID.equal(getCustomerId())).findAny().orElse(null);
}
@Override
public Staff findStaffId(Manager foreignManager) {
return foreignManager.stream().filter(Staff.STAFF_ID.equal(getStaffId())).findAny().orElse(null);
}
@Override
public String toString() {
final StringJoiner sj = new StringJoiner(", ", "{ ", " }");
sj.add("rentalId = " + Objects.toString(getRentalId()));
sj.add("rentalDate = " + Objects.toString(getRentalDate()));
sj.add("inventoryId = " + Objects.toString(getInventoryId()));
sj.add("customerId = " + Objects.toString(getCustomerId()));
sj.add("returnDate = " + Objects.toString(OptionalUtil.unwrap(getReturnDate())));
sj.add("staffId = " + Objects.toString(getStaffId()));
sj.add("lastUpdate = " + Objects.toString(getLastUpdate()));
return "RentalImpl " + sj.toString();
}
@Override
public boolean equals(Object that) {
if (this == that) { return true; }
if (!(that instanceof Rental)) { return false; }
final Rental thatRental = (Rental)that;
if (this.getRentalId() != thatRental.getRentalId()) {return false; }
if (!Objects.equals(this.getRentalDate(), thatRental.getRentalDate())) {return false; }
if (this.getInventoryId() != thatRental.getInventoryId()) {return false; }
if (this.getCustomerId() != thatRental.getCustomerId()) {return false; }
if (!Objects.equals(this.getReturnDate(), thatRental.getReturnDate())) {return false; }
if (this.getStaffId() != thatRental.getStaffId()) {return false; }
if (!Objects.equals(this.getLastUpdate(), thatRental.getLastUpdate())) {return false; }
return true;
}
@Override
public int hashCode() {
int hash = 7;
hash = 31 * hash + Integer.hashCode(getRentalId());
hash = 31 * hash + Objects.hashCode(getRentalDate());
hash = 31 * hash + Integer.hashCode(getInventoryId());
hash = 31 * hash + Integer.hashCode(getCustomerId());
hash = 31 * hash + Objects.hashCode(getReturnDate());
hash = 31 * hash + Short.hashCode(getStaffId());
hash = 31 * hash + Objects.hashCode(getLastUpdate());
return hash;
}
}