
test.googlecode.genericdao.model.RecipeIngredientId Maven / Gradle / Ivy
/* Copyright 2009 The Revere Group
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.googlecode.genericdao.model;
import java.io.Serializable;
import javax.persistence.Embeddable;
import javax.persistence.ManyToOne;
@Embeddable
public class RecipeIngredientId implements Serializable {
private static final long serialVersionUID = 0L;
private Recipe recipe;
private Ingredient ingredient;
public RecipeIngredientId() {
}
public RecipeIngredientId(Recipe recipe, Ingredient ingredient) {
super();
this.recipe = recipe;
this.ingredient = ingredient;
}
@ManyToOne
public Recipe getRecipe() {
return recipe;
}
public void setRecipe(Recipe recipe) {
this.recipe = recipe;
}
@ManyToOne
public Ingredient getIngredient() {
return ingredient;
}
public void setIngredient(Ingredient ingredient) {
this.ingredient = ingredient;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((ingredient == null) ? 0 : ingredient.hashCode());
result = prime * result + ((recipe == null) ? 0 : recipe.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
RecipeIngredientId other = (RecipeIngredientId) obj;
if (ingredient == null) {
if (other.ingredient != null)
return false;
} else if (!ingredient.equals(other.ingredient))
return false;
if (recipe == null) {
if (other.recipe != null)
return false;
} else if (!recipe.equals(other.recipe))
return false;
return true;
}
public String toString() {
return "RecipeIngredientId::recipeId:" + (recipe == null ? "(none)" : recipe.getId()) + ",ingredientId:" + (ingredient == null ? "(none)" : ingredient.getIngredientId());
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy