Modified Message and its subclasses to work nicely with jackson
This commit is contained in:
parent
f5eed945a2
commit
e41dc70f97
7 changed files with 58 additions and 0 deletions
|
|
@ -10,6 +10,8 @@ import commons.Ingredient;
|
|||
public class CreateIngredientMessage implements Message {
|
||||
private Ingredient ingredient;
|
||||
|
||||
public CreateIngredientMessage() {} // for jackson
|
||||
|
||||
public CreateIngredientMessage(Ingredient ingredient) {
|
||||
this.ingredient = ingredient;
|
||||
}
|
||||
|
|
@ -27,4 +29,9 @@ public class CreateIngredientMessage implements Message {
|
|||
public Ingredient getIngredient() {
|
||||
return ingredient;
|
||||
}
|
||||
|
||||
// for jackson
|
||||
public void setIngredient(Ingredient ingredient) {
|
||||
this.ingredient = ingredient;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@ import commons.Recipe;
|
|||
public class CreateRecipeMessage implements Message {
|
||||
private Recipe recipe;
|
||||
|
||||
public CreateRecipeMessage() {} // for jackson
|
||||
|
||||
public CreateRecipeMessage(Recipe recipe) {
|
||||
this.recipe = recipe;
|
||||
}
|
||||
|
|
@ -27,4 +29,9 @@ public class CreateRecipeMessage implements Message {
|
|||
public Recipe getRecipe() {
|
||||
return recipe;
|
||||
}
|
||||
|
||||
// for jackson
|
||||
public void setRecipe(Recipe recipe) {
|
||||
this.recipe = recipe;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@ package commons.ws.messages;
|
|||
public class DeleteIngredientMessage implements Message {
|
||||
private Long ingredientId;
|
||||
|
||||
public DeleteIngredientMessage() {} // for jackson
|
||||
|
||||
public DeleteIngredientMessage(Long ingredientId) {
|
||||
this.ingredientId = ingredientId;
|
||||
}
|
||||
|
|
@ -25,4 +27,9 @@ public class DeleteIngredientMessage implements Message {
|
|||
public Long getIngredientId() {
|
||||
return ingredientId;
|
||||
}
|
||||
|
||||
// for jackson
|
||||
public void setIngredientId(Long ingredientId) {
|
||||
this.ingredientId = ingredientId;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@ package commons.ws.messages;
|
|||
public class DeleteRecipeMessage implements Message {
|
||||
private Long recipeId;
|
||||
|
||||
public DeleteRecipeMessage() {} // for jackson
|
||||
|
||||
public DeleteRecipeMessage(Long recipeId) {
|
||||
this.recipeId = recipeId;
|
||||
}
|
||||
|
|
@ -25,4 +27,9 @@ public class DeleteRecipeMessage implements Message {
|
|||
public Long getRecipeId() {
|
||||
return recipeId;
|
||||
}
|
||||
|
||||
// for jackson
|
||||
public void setRecipeId(Long recipeId) {
|
||||
this.recipeId = recipeId;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,21 @@
|
|||
package commons.ws.messages;
|
||||
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonSubTypes;
|
||||
import com.fasterxml.jackson.annotation.JsonTypeInfo;
|
||||
|
||||
@JsonTypeInfo(
|
||||
use = JsonTypeInfo.Id.NAME,
|
||||
property = "type"
|
||||
)
|
||||
@JsonSubTypes({
|
||||
@JsonSubTypes.Type(value = CreateRecipeMessage.class, name = "RECIPE_CREATE"),
|
||||
@JsonSubTypes.Type(value = UpdateRecipeMessage.class, name = "RECIPE_UPDATE"),
|
||||
@JsonSubTypes.Type(value = DeleteRecipeMessage.class, name = "RECIPE_DELETE"),
|
||||
@JsonSubTypes.Type(value = CreateIngredientMessage.class, name = "INGREDIENT_CREATE"),
|
||||
@JsonSubTypes.Type(value = UpdateIngredientMessage.class, name = "INGREDIENT_UPDATE"),
|
||||
@JsonSubTypes.Type(value = DeleteIngredientMessage.class, name = "INGREDIENT_DELETE")
|
||||
})
|
||||
public interface Message {
|
||||
public enum Type {
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@ import commons.Ingredient;
|
|||
public class UpdateIngredientMessage implements Message {
|
||||
private Ingredient ingredient;
|
||||
|
||||
public UpdateIngredientMessage() {} // for jackson
|
||||
|
||||
public UpdateIngredientMessage(Ingredient ingredient) {
|
||||
this.ingredient = ingredient;
|
||||
}
|
||||
|
|
@ -27,4 +29,9 @@ public class UpdateIngredientMessage implements Message {
|
|||
public Ingredient getIngredient() {
|
||||
return ingredient;
|
||||
}
|
||||
|
||||
// for jackson
|
||||
public void setIngredient(Ingredient ingredient) {
|
||||
this.ingredient = ingredient;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@ import commons.Recipe;
|
|||
public class UpdateRecipeMessage implements Message {
|
||||
private Recipe recipe;
|
||||
|
||||
public UpdateRecipeMessage() {} // for jackson
|
||||
|
||||
public UpdateRecipeMessage(Recipe recipe) {
|
||||
this.recipe = recipe;
|
||||
}
|
||||
|
|
@ -27,4 +29,9 @@ public class UpdateRecipeMessage implements Message {
|
|||
public Recipe getRecipe() {
|
||||
return recipe;
|
||||
}
|
||||
|
||||
// for jackson
|
||||
public void setRecipe(Recipe recipe) {
|
||||
this.recipe = recipe;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue