StockLevelRegion.java
package com.tradecloud.domain.model.requestforquote;
import com.tradecloud.domain.place.Region;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
@Entity
@Table(name = "StockLevelRegion")
@Access(AccessType.FIELD)
public class StockLevelRegion extends StockLevelRow{
@ManyToOne
@NotNull(message = "stockLevelStyle should not be null")
private StockLevelStyle stockLevelStyle;
@ManyToOne
@NotNull(message = "region should not be null")
private Region region;
@OneToMany(mappedBy = "stockLevelRegion", cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.EAGER)
private List<StockLevelStyleProduct> stockLevelStyleProducts=new ArrayList<>();
public StockLevelRegion(){
}
public StockLevelRegion(Region region, StockLevelStyle stockLevelStyle) {
this.region = region;
this.stockLevelStyle = stockLevelStyle;
}
public StockLevelStyle getStockLevelStyle() {
return stockLevelStyle;
}
public void setStockLevelStyle(StockLevelStyle stockLevelStyle) {
this.stockLevelStyle = stockLevelStyle;
}
public List<StockLevelStyleProduct> getStockLevelStyleProducts() {
return stockLevelStyleProducts;
}
public void setStockLevelStyleProducts(List<StockLevelStyleProduct> stockLevelStyleProducts) {
this.stockLevelStyleProducts = stockLevelStyleProducts;
}
public Region getRegion() {
return region;
}
public void setRegion(Region region) {
this.region = region;
}
@Override
public boolean equals(Object object) {
if (this == object) return true;
if (object == null || getClass() != object.getClass()) return false;
if (!super.equals(object)) return false;
StockLevelRegion that = (StockLevelRegion) object;
return Objects.equals(stockLevelStyle, that.stockLevelStyle) && Objects.equals(region, that.region);
}
@Override
public int hashCode() {
return Objects.hash(super.hashCode(), stockLevelStyle, region);
}
@Override
public String getStyle() {
return region.getName();
}
@Override
public boolean isRegion(){
return true;
}
}