SolrServer.java have "add()" methods. But, "server.add()" is failed. is If I use as follows:
in my abstract class:
public abstract void addDocs( Class<? extends SolrServer> server ) throws IOException, SolrServerException;
in my Implementataon class:
@Override
public void addDocs(Class<? extends SolrServer> server) throws IOException, SolrServerException {
...
server.add(doc);
}

No problem, If I use as follows:
@Override
public void addDocs(SolrServer server) throws IOException, SolrServerException {
...
server.add(doc);
}

What is wrong?
UPDATE:
SolrServer.java is an abstact class. For this reason, the problem could be?
a) if you just use this:
public void addDocs(SolrServer server) throws IOException, SolrServerException {
...
server.add(doc);
}
you should be able to call this method with any Sub-class of SolrServer as well
b) you could also define a Type Variable:
public <S extends SolrServer> void addDocs(S server) throws AllKindsOfStuff{
...
server.add(doc);
}
However, you are trying to operate on classes, not on Objects. Change the parameter type from Class<? extends SolrServer> to SolrServer and you should be fine
Ok, since you have a base class, declare the Type Variable in that base class:
public abstract class BaseClass<S extends SolrServer>{
public abstract void addDocs(S server);
}
public class ImplementingClass extends BaseClass<SomeSolrServer>{
public void addDocs(SomeSolrServer server){
// do stuff here
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With