]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.db.common/src/org/simantics/db/common/procedure/adapter/CacheListener.java
More DB ListenerAdapter abstract to force isDisposed implementation
[simantics/platform.git] / bundles / org.simantics.db.common / src / org / simantics / db / common / procedure / adapter / CacheListener.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.procedure.Listener;
15
16 /*
17  * Use this listener to ensure caching for a request. This listener will not lock the request in cache.
18  * 
19  */
20 final public class CacheListener<T> implements Listener<T> {
21
22     final private ListenerSupport support;
23
24     public CacheListener(ListenerSupport support) {
25         this.support = support;
26     }
27
28     @Override
29     final public void exception(Throwable throwable) {
30         support.exception(throwable);
31     }
32
33     @Override
34     final public boolean isDisposed() {
35         return support.isDisposed();
36     }
37
38     @Override
39     public void execute(T result) {
40     }
41
42     @Override
43     public int hashCode() {
44         return support.hashCode();
45     }
46
47     @Override
48     public boolean equals(Object object) {
49         if (this == object)
50             return true;
51         else if (object == null)
52             return false;
53         else if (CacheListener.class != object.getClass())
54             return false;
55         CacheListener<?> r = (CacheListener<?>)object;
56         return r.support.equals(support);
57     }
58
59 }