package com.company.sakila.db0.sakila.address.generated;
import com.company.sakila.db0.sakila.address.Address;
import com.company.sakila.db0.sakila.city.City;
import com.speedment.common.annotation.GeneratedCode;
import com.speedment.runtime.core.manager.Manager;
import com.speedment.runtime.core.util.OptionalUtil;
import java.sql.Blob;
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.address.Address}-interface.
* <p>
* This file has been automatically generated by Speedment. Any changes made to
* it will be overwritten.
*
* @author Speedment
*/
@GeneratedCode("Speedment")
public abstract class GeneratedAddressImpl implements Address {
private int addressId;
private String address;
private String address2;
private String district;
private int cityId;
private String postalCode;
private String phone;
private Blob location;
private Timestamp lastUpdate;
protected GeneratedAddressImpl() {
}
@Override
public int getAddressId() {
return addressId;
}
@Override
public String getAddress() {
return address;
}
@Override
public Optional<String> getAddress2() {
return Optional.ofNullable(address2);
}
@Override
public String getDistrict() {
return district;
}
@Override
public int getCityId() {
return cityId;
}
@Override
public Optional<String> getPostalCode() {
return Optional.ofNullable(postalCode);
}
@Override
public String getPhone() {
return phone;
}
@Override
public Blob getLocation() {
return location;
}
@Override
public Timestamp getLastUpdate() {
return lastUpdate;
}
@Override
public Address setAddressId(int addressId) {
this.addressId = addressId;
return this;
}
@Override
public Address setAddress(String address) {
this.address = address;
return this;
}
@Override
public Address setAddress2(String address2) {
this.address2 = address2;
return this;
}
@Override
public Address setDistrict(String district) {
this.district = district;
return this;
}
@Override
public Address setCityId(int cityId) {
this.cityId = cityId;
return this;
}
@Override
public Address setPostalCode(String postalCode) {
this.postalCode = postalCode;
return this;
}
@Override
public Address setPhone(String phone) {
this.phone = phone;
return this;
}
@Override
public Address setLocation(Blob location) {
this.location = location;
return this;
}
@Override
public Address setLastUpdate(Timestamp lastUpdate) {
this.lastUpdate = lastUpdate;
return this;
}
@Override
public City findCityId(Manager<City> foreignManager) {
return foreignManager.stream().filter(City.CITY_ID.equal(getCityId())).findAny().orElse(null);
}
@Override
public String toString() {
final StringJoiner sj = new StringJoiner(", ", "{ ", " }");
sj.add("addressId = " + Objects.toString(getAddressId()));
sj.add("address = " + Objects.toString(getAddress()));
sj.add("address2 = " + Objects.toString(OptionalUtil.unwrap(getAddress2())));
sj.add("district = " + Objects.toString(getDistrict()));
sj.add("cityId = " + Objects.toString(getCityId()));
sj.add("postalCode = " + Objects.toString(OptionalUtil.unwrap(getPostalCode())));
sj.add("phone = " + Objects.toString(getPhone()));
sj.add("location = " + Objects.toString(getLocation()));
sj.add("lastUpdate = " + Objects.toString(getLastUpdate()));
return "AddressImpl " + sj.toString();
}
@Override
public boolean equals(Object that) {
if (this == that) { return true; }
if (!(that instanceof Address)) { return false; }
final Address thatAddress = (Address)that;
if (this.getAddressId() != thatAddress.getAddressId()) {return false; }
if (!Objects.equals(this.getAddress(), thatAddress.getAddress())) {return false; }
if (!Objects.equals(this.getAddress2(), thatAddress.getAddress2())) {return false; }
if (!Objects.equals(this.getDistrict(), thatAddress.getDistrict())) {return false; }
if (this.getCityId() != thatAddress.getCityId()) {return false; }
if (!Objects.equals(this.getPostalCode(), thatAddress.getPostalCode())) {return false; }
if (!Objects.equals(this.getPhone(), thatAddress.getPhone())) {return false; }
if (!Objects.equals(this.getLocation(), thatAddress.getLocation())) {return false; }
if (!Objects.equals(this.getLastUpdate(), thatAddress.getLastUpdate())) {return false; }
return true;
}
@Override
public int hashCode() {
int hash = 7;
hash = 31 * hash + Integer.hashCode(getAddressId());
hash = 31 * hash + Objects.hashCode(getAddress());
hash = 31 * hash + Objects.hashCode(getAddress2());
hash = 31 * hash + Objects.hashCode(getDistrict());
hash = 31 * hash + Integer.hashCode(getCityId());
hash = 31 * hash + Objects.hashCode(getPostalCode());
hash = 31 * hash + Objects.hashCode(getPhone());
hash = 31 * hash + Objects.hashCode(getLocation());
hash = 31 * hash + Objects.hashCode(getLastUpdate());
return hash;
}
}