I have a Java method which has to accept generic object.
Public void myMethod(Object<T> anyClassObject) {
//handle code
}
The method should accept object of any class and I have to manage the content of the object. I am not an expert in Generics. So please help me to achieve this using Generics.
my need is to create a method which any class's instance. And then I have to save the object in database.
For saving into database, have to specify the persistent entity class as usual.
For example,
mongoTemplate.createCollection(One.class)
For an other entity,
mongoTemplate.createCollection(Two.class)
like the above.
I have to write a method which can be accessed in common
Objectis good enough)