/*******************************************************************************
- * Copyright (c) 2007, 2010 Association for Decentralized Information Management
+ * Copyright (c) 2007, 2018 Association for Decentralized Information Management
* in Industry THTH ry.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
*******************************************************************************/
package org.simantics.db.common.primitiverequest;
-import org.simantics.db.AsyncReadGraph;
+import org.simantics.db.ReadGraph;
import org.simantics.db.Resource;
-import org.simantics.db.procedure.AsyncProcedure;
-import org.simantics.db.request.AsyncRead;
+import org.simantics.db.adaption.AdaptionService;
+import org.simantics.db.common.request.BinaryRead;
+import org.simantics.db.exception.DatabaseException;
-final public class PossibleAdapter<T> implements AsyncRead<T> {
+public final class PossibleAdapter<T> extends BinaryRead<Resource,Class<T>, T> {
- final private Resource resource;
- final private Class<T> clazz;
-
- @Override
- public int hashCode() {
- return resource.hashCode() + 31 * clazz.hashCode();
- }
-
- @Override
- public boolean equals(Object object) {
- if (this == object)
- return true;
- else if (object == null)
- return false;
- else if (getClass() != object.getClass())
- return false;
- PossibleAdapter<?> r = (PossibleAdapter<?>)object;
- return resource.equals(r.resource) && clazz.equals(r.clazz);
- }
-
- @Override
- public int threadHash() {
- return hashCode();
- }
-
- @Override
- public int getFlags() {
- return 0;
- }
-
public PossibleAdapter(Resource resource, Class<T> clazz) {
- this.resource = resource;
- this.clazz = clazz;
+ super(resource, clazz);
}
@Override
- public void perform(AsyncReadGraph graph, AsyncProcedure<T> procedure) {
-
- graph.forPossibleAdapted(resource, clazz, procedure);
-
+ public T perform(ReadGraph graph) throws DatabaseException {
+ final AdaptionService service = graph.peekService(AdaptionService.class);
+ return service.adapt(graph, parameter, parameter, Resource.class, parameter2, true);
}
}