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