1 /*******************************************************************************
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
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
10 * VTT Technical Research Centre of Finland - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.browsing.ui.graph.impl;
14 import org.simantics.browsing.ui.NodeContext;
15 import org.simantics.db.request.Read;
18 * A database query which identifies itself by two fields: an abstract
19 * idenfitier and an INodeContext.
21 * @author Antti Villberg
25 public abstract class ResourceQuery<T> implements Read<T> {
27 protected final Object queryIdentifier;
28 protected final NodeContext context;
31 public ResourceQuery(Object queryIdentifier, NodeContext context) {
32 assert queryIdentifier != null;
33 assert context != null;
34 this.queryIdentifier = queryIdentifier;
35 this.context = context;
36 this.hash = makeHash();
40 public boolean equals(Object object) {
44 else if (object == null)
46 else if (!(object instanceof ResourceQuery<?>))
49 ResourceQuery<?> query = (ResourceQuery<?>) object;
50 return getClass() == query.getClass() && queryIdentifier.equals(query.queryIdentifier) && context.equals(query.context);
54 protected int makeHash() {
55 return getClass().hashCode() * 31 + context.hashCode() * 41 + queryIdentifier.hashCode();
59 final public int hashCode() {