I have an interface in which I want to provide a default method for serializing inherited classes. I use the class JsonSerializer<T>for serialization.
The method looks like this:
public interface A
{
public default String write()
{
new JsonSerializer<>();
}
}
public class AX implements A
{
}
So when I create an AX instance, I want to use the write method to serialize AX
AX inst = new AX();
String instSerialized = inst.write();
I need to pass type AX to the write method in A. Is this possible?
source
share