]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.browsing.ui.graph.impl/src/org/simantics/browsing/ui/graph/impl/ParametrizedResourceQuery.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.browsing.ui.graph.impl / src / org / simantics / browsing / ui / graph / impl / ParametrizedResourceQuery.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.browsing.ui.graph.impl;
13
14 import java.util.Arrays;
15
16 import org.simantics.browsing.ui.NodeContext;
17
18 /**
19  * @author Tuukka Lehtonen
20  *
21  * @param <T>
22  */
23 public abstract class ParametrizedResourceQuery<T> extends ResourceQuery<T> {
24
25     Object[] parameters;
26
27     public ParametrizedResourceQuery(Object queryIdentifier, NodeContext context, Object... parameters) {
28         super(queryIdentifier, context);
29         this.parameters = parameters;
30         this.hash = makeHash();
31     }
32
33     @Override
34     public boolean equals(Object object) {
35
36         if (this == object)
37             return true;
38         else if (object == null)
39             return false;
40         else if (!(object instanceof ParametrizedResourceQuery<?>))
41             return false;
42
43         ParametrizedResourceQuery<?> query = (ParametrizedResourceQuery<?>) object;
44         return queryIdentifier.equals(query.queryIdentifier)
45         && context.equals(query.context)
46         && Arrays.equals(parameters, query.parameters);
47     }
48
49     @Override
50     protected int makeHash() {
51         return (context.hashCode() * 31 + queryIdentifier.hashCode()) * 31 + Arrays.hashCode(parameters);
52     }
53
54 }