You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
48 lines
1.1 KiB
Java
48 lines
1.1 KiB
Java
4 years ago
|
import java.util.Objects;
|
||
|
|
||
|
public class StreamProduct {
|
||
|
private final int id;
|
||
|
private final String name;
|
||
|
private final int weight;
|
||
|
|
||
|
public StreamProduct(final int id, final String name, final int weight) {
|
||
|
this.id = id;
|
||
|
this.name = name;
|
||
|
this.weight = weight;
|
||
|
}
|
||
|
|
||
|
public String getName() {
|
||
|
return name;
|
||
|
}
|
||
|
|
||
|
public int getWeight() {
|
||
|
return weight;
|
||
|
}
|
||
|
|
||
|
public int getId() {
|
||
|
return id;
|
||
|
}
|
||
|
|
||
|
public String toString() {
|
||
|
return "Product{" +
|
||
|
"id=" + id +
|
||
|
", name='" + name + '\'' +
|
||
|
", weight=" + weight +
|
||
|
'}';
|
||
|
}
|
||
|
|
||
|
public boolean equals(final Object o) {
|
||
|
if (!(o instanceof StreamProduct)) return false;
|
||
|
|
||
|
final StreamProduct streamProduct = (StreamProduct) o;
|
||
|
|
||
|
return Objects.equals(id, streamProduct.id)
|
||
|
&& Objects.equals(weight, streamProduct.weight)
|
||
|
&& Objects.equals(name, streamProduct.name);
|
||
|
}
|
||
|
|
||
|
public int hashCode() {
|
||
|
return Objects.hash(id, name, weight);
|
||
|
}
|
||
|
}
|