1 /*******************************************************************************
2 * Copyright (c) 2007, 2018 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.db.impl.query;
14 import org.simantics.db.exception.DatabaseException;
15 import org.simantics.db.impl.graph.ReadGraphImpl;
16 import org.simantics.db.request.RequestFlags;
18 import gnu.trove.list.array.TByteArrayList;
20 public abstract class UnaryQuery<Procedure> extends CacheEntryBase<Procedure> implements Query {
24 public UnaryQuery(int r) {
36 return RequestFlags.INVALIDATE;
40 final public boolean equals(Object object) {
43 else if (object == null)
45 else if (getClass() != object.getClass())
47 UnaryQuery<?> other = (UnaryQuery<?>)object;
48 return id == other.id;
52 final public Query getQuery() {
53 assert(!isDiscarded());
57 abstract public void removeEntry(QueryProcessor provider);
59 public Object get(ReadGraphImpl graph, Procedure procedure) throws Throwable {
60 if(procedure != null) {
61 performFromCache(graph, procedure);
69 boolean isImmutable(ReadGraphImpl graph) throws DatabaseException {
70 return graph.processor.isImmutable(id);
74 public long cluster(QueryProcessor processor) {
75 return processor.cluster(id);
79 public void serializeKey(QuerySerializer serializer) {
80 serializer.addResource(id);