Commit 484d79dd authored by Lukas Jelonek's avatar Lukas Jelonek
Browse files

Added getInstance Method to DbXRefService

parent 5f8c2d70
......@@ -18,18 +18,36 @@ package de.cebitec.common.dbxref;
import de.cebitec.common.dbxref.api.DbXRef;
import de.cebitec.common.dbxref.api.Resource;
import de.cebitec.common.dbxref.api.Resource.Type;
import java.util.Collection;
import java.util.Iterator;
import java.util.ServiceLoader;
/**
* A DbXRefService resolves dbxrefs to resources. In order to obtain a dbxref use the factory methods.
*
* @see #create(CharSequence)
* @see #create(CharSequence, CharSequence)
*
* @see #create(CharSequence)
* @see #create(CharSequence, CharSequence)
*
* @author Lukas Jelonek {@literal <Lukas.Jelonek at computational.bio.uni-giessen.de>}
*/
public interface DbXRefService {
/**
* Retrieves an instance of DbXRefService via the serviceloader.
*
* @return
*/
static DbXRefService getInstance() {
ServiceLoader<DbXRefService> loader = ServiceLoader.load(DbXRefService.class);
final Iterator<DbXRefService> it = loader.iterator();
if (it.hasNext()) {
return it.next();
} else {
return DbXRefResourceRegistry.getDefault();
}
}
/**
* Factory method for database cross references. Can instantiate any database cross reference, regardless of a valid
* database or valid identifier.
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment