]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.db.common/src/org/simantics/db/common/procedure/adapter/ResourceAsyncListenerDelegate.java
More DB ListenerAdapter abstract to force isDisposed implementation
[simantics/platform.git] / bundles / org.simantics.db.common / src / org / simantics / db / common / procedure / adapter / ResourceAsyncListenerDelegate.java
1 /*******************************************************************************
2  * Copyright (c) 2007, 2010 Association for Decentralized Information Management
3  * in Industry THTH ry.
4  * All rights reserved. This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License v1.0
6  * which accompanies this distribution, and is available at
7  * http://www.eclipse.org/legal/epl-v10.html
8  *
9  * Contributors:
10  *     VTT Technical Research Centre of Finland - initial API and implementation
11  *******************************************************************************/
12 package org.simantics.db.common.procedure.adapter;
13
14 import org.simantics.db.AsyncReadGraph;
15 import org.simantics.db.Resource;
16 import org.simantics.db.procedure.AsyncListener;
17
18 abstract public class ResourceAsyncListenerDelegate<T> implements AsyncListener<T> {
19     
20         final private Resource resource;
21     final private AsyncListenerSupport support;
22     
23     public ResourceAsyncListenerDelegate(Resource resource, AsyncListenerSupport support) {
24         this.resource = resource;
25         this.support = support;
26     }
27
28     @Override
29     final public void exception(AsyncReadGraph graph, Throwable throwable) {
30         support.exception(graph, throwable);
31     }
32
33     @Override
34     final public boolean isDisposed() {
35         return support.isDisposed();
36     }
37
38     @Override
39     public int hashCode() {
40         return resource.hashCode();
41     }
42
43     @Override
44     public boolean equals(Object object) {
45         if (this == object)
46             return true;
47         else if (object == null)
48             return false;
49         else if (getClass() != object.getClass())
50             return false;
51         ResourceAsyncListenerDelegate<?> r = (ResourceAsyncListenerDelegate<?>) object;
52         return resource.equals(r.resource);
53     }
54
55 }