Always use try-with-resources when using Streams, because the Streams can contain an open database connection.
try (Stream<String> data = database.getData()) {
...
}the interface
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "@type")
@JsonSubTypes({
// make sure name is the same as the value of @JsonTypeName in Implementation
@JsonSubTypes.Type(name= "Implementation", value = Implementation.class)
})
public interface Interface {
...
}one of the implementing classes
@JsonTypeName("Implementation") // make sure this name is the same as the name specified in Interface
public class Implementation implements Interface {
...
}