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
10 * VTT Technical Research Centre of Finland - initial API and implementation
\r
11 *******************************************************************************/
\r
12 package org.simantics.db.impl.query;
\r
14 import org.simantics.db.procedure.ListenerBase;
\r
16 class ListenerEntry {
\r
18 public static final Object NO_VALUE = new Object() {
\r
20 public String toString() { return "NO_VALUE"; };
\r
23 public static final Object NOT_CHANGED = new Object() {
\r
25 public String toString() { return "NOT_CHANGED"; };
\r
29 public ListenerBase base;
\r
30 public Object procedure;
\r
31 public CacheEntry entry;
\r
33 private Object lastKnownResult;
\r
35 public ListenerEntry(CacheEntry entry, ListenerBase base, Object procedure) {
\r
38 this.procedure = procedure;
\r
39 if(entry.isReady()) {
\r
40 this.lastKnownResult = entry.getResult();
\r
42 this.lastKnownResult = NO_VALUE;
\r
46 public void setLastKnown(Object object) {
\r
47 lastKnownResult = object;
\r
50 public Object getLastKnown() {
\r
51 return lastKnownResult;
\r
55 public String toString() {
\r
56 // return "[ListenerEntry last = " + lastKnownResult + ", procedure = " + procedure + "]";
\r
57 return "[ListenerEntry " + ", procedure = " + procedure + " base=" + base + "]";
\r
61 public int hashCode() {
\r
62 return base.hashCode();
\r
66 public boolean equals(Object obj) {
\r
68 if(obj == this) return true;
\r
69 if(obj == null) return false;
\r
70 if(obj.getClass() != this.getClass()) return false;
\r
71 ListenerEntry other = (ListenerEntry)obj;
\r
72 return base.equals(other.base);
\r