I am studying Spring with Spring In Action book, i have the code from the book where it works fine:
@Slf4j
@Controller
@RequestMapping("/design")
public class DesignTacoController {
@GetMapping
public String showDesignForm(Model model) {
List<Ingredient> ingredients = Arrays.asList(
new Ingredient("FLTO", "Flour Tortilla", Type.WRAP),
new Ingredient("COTO", "Corn Tortilla", Type.WRAP),
new Ingredient("GRBF", "Ground Beef", Type.PROTEIN),
);
Type[] types = Ingredient.Type.values();
for (Type type : types) {
model.addAttribute(type.toString().toLowerCase(),
filterByType(ingredients, type));
}
model.addAttribute("design", new Taco());
return "design";
}
}
but when i typed it in my IDEA it says that method filterByType cannot be resolved, but there is no such problem in the book, and no any comment about this problem. I am new in the Spring, tried google a lot, but couldn't find any information about this problem and it source. Could you help me with this problem, a cannot move further because of it. screenshot from IDEA
Select the Only unresolved/unloaded radio button. Then, click the Find button. You see a list of all unresolved and unloaded elements in the model. Delete the reference to the missing element from the model for each search result or restore the element in question.
How do you correct for unresolved and unloaded references in an IBM Rational Rhapsody model? When an element is removed from a model, Rhapsody cannot delete any read-only references to that element. Upon removal of the original model element, these lingering references appear with a (U) symbol.
But then a bug is discovered that either might be related to the equals method not reflecting the newly added attributes that could potentially lead to overwriting data entities in collections or a crucial log message does not give a programmer the values of the added attributes because the toString method has not been updated.
It looks like this book just contains an error, it does not list the filterByType()
method. It's not a Spring method. Here you go:
private List<Ingredient> filterByType(List<Ingredient> ingredients, Type type) {
return ingredients.stream()
.filter(x -> x.getType().equals(type))
.collect(Collectors.toList());
}
Source: Manning Publications
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With