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.browsing.ui.graph.impl;
\r
14 import org.simantics.browsing.ui.NodeContext;
\r
15 import org.simantics.db.request.Read;
\r
18 * A database query which identifies itself by two fields: an abstract
\r
19 * idenfitier and an INodeContext.
\r
21 * @author Antti Villberg
\r
25 public abstract class ResourceQuery<T> implements Read<T> {
\r
27 protected final Object queryIdentifier;
\r
28 protected final NodeContext context;
\r
31 public ResourceQuery(Object queryIdentifier, NodeContext context) {
\r
32 assert queryIdentifier != null;
\r
33 assert context != null;
\r
34 this.queryIdentifier = queryIdentifier;
\r
35 this.context = context;
\r
36 this.hash = makeHash();
\r
40 public boolean equals(Object object) {
\r
44 else if (object == null)
\r
46 else if (!(object instanceof ResourceQuery<?>))
\r
49 ResourceQuery<?> query = (ResourceQuery<?>) object;
\r
50 return getClass() == query.getClass() && queryIdentifier.equals(query.queryIdentifier) && context.equals(query.context);
\r
54 protected int makeHash() {
\r
55 return getClass().hashCode() * 31 + context.hashCode() * 41 + queryIdentifier.hashCode();
\r
59 final public int hashCode() {
\r