Module 6 Mapping Json

How do i map the stocks to the Candle as its an interface shouldn’t it be the TiingoCandle class instead?

Refer to the knowledge that you have gained from module 4, where you used portfolioManager as an interface and called its functions :slight_smile:
You can refer to the following FAQ :slight_smile:

In module 4 I changed the method signature and returned TiingoCandle instead of Candle.
How should i do this as in this module two classes are there which implement the Candle interface? How do i map them to the same interface and return it?

I’ll recommend you let the method return type be of List and try returning a TiingoCandle/AlphavantageCandle type list. It should work.

If you still have any confusion, refer to this article as how to move forward using candle interface and tiingocandle class.

See this article in geeks for geeks

Try to understand why we need this. There are several factors we dealing with.
It is used to achieve total abstraction. Since java does not support multiple inheritance in case of class, but by using interface it can achieve multiple inheritance . It is also used to achieve loose coupling. Interfaces are used to implement abstraction.

Now you just need to store reference in List for objects of TiingoCandle which is possible because TiingoCandle implements Candle interface.

Did you get the solution yet? I am having the same doubt.

As you know candle is an interface so you can use TiingoCandle for mapping the response and then store the object in the candle list and use it.

1 Like