kontent-ai / kontent-ai/java-packages
Nested support for Custom Models
- Dominant language
- Java
- Stars
- 17
- Forks
- 27
- PR merge metrics
- No merged PRs in 30d
Description
### Motivation
I want to fetch my model `A` class using `client.getItems(A.class, params)`. The problem is that conversion for custom types is not working deeper in hierarchy.
```
@ContentItemMapping("a")
class A {
@ContentItemMapping("b") List bList;
}
@ContentItemMapping("b")
class B {
@ElementMapping("name") String name;
@ContentItemMapping("b") List cList;
}
@ContentItemMapping("c")
class C {
@ElementMapping("name") String name;
}
```
Class `A` will contain list of `B` classes, but inside this class `List cList` will be mapped to empty list (String name inside `B` class is ok).
If i fetch class `B` direcly using `client.getItems(B.class, params)`, `List cList` will be mapped correctly. So it seems it's not working only if im deeper in hierarchy.
### Proposed solution
Add support to nested custom models mapping.
### Additional context
There is also parameter `linkedItemsDepth(int)`, but it seems that this is only valid for `ContentItem` object model, not custom models.
Contributor guide
Research direction
Start by tracing client.getItems(A.class, params) and compare nested custom-model conversion with direct client.getItems(B.class, params). Check how linkedItemsDepth(int) is applied to ContentItem versus custom models. Done means the A → B → C example maps cList and its name values correctly.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100