X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.diagram%2Fsrc%2Forg%2Fsimantics%2Fdiagram%2Fadapter%2FBaseRequest.java;h=26e46dd06e806df4c39863013fd7d82d32410329;hb=617b9475710b80a125597f222f9777224972ce72;hp=ea3ad0f5fac402bbbe453d8b544b8e73e8a2643c;hpb=969bd23cab98a79ca9101af33334000879fb60c5;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.diagram/src/org/simantics/diagram/adapter/BaseRequest.java b/bundles/org.simantics.diagram/src/org/simantics/diagram/adapter/BaseRequest.java index ea3ad0f5f..26e46dd06 100644 --- a/bundles/org.simantics.diagram/src/org/simantics/diagram/adapter/BaseRequest.java +++ b/bundles/org.simantics.diagram/src/org/simantics/diagram/adapter/BaseRequest.java @@ -1,66 +1,66 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 Association for Decentralized Information Management - * in Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.diagram.adapter; - -import org.simantics.db.request.Read; -import org.simantics.g2d.canvas.ICanvasContext; - -/** - * A base for synchronous requests performed by - * {@link GraphToDiagramSynchronizer}. - * - *

- * Takes care of making this request unique for this - * {@link GraphToDiagramSynchronizer} instances by making the active - * {@link ICanvasContext} a part of the requests identity. - *

- * - * @param type of stored data element - * @param query result type - */ -abstract class BaseRequest implements Read { - - final protected T data; - - final int hash; - - final ICanvasContext canvas; - - public BaseRequest(ICanvasContext canvas, T data) { - this.canvas = canvas; - assert canvas != null; - assert data != null; - this.data = data; - this.hash = data.hashCode() + 31 * canvas.hashCode(); - } - - @Override - public int hashCode() { - return hash; - } - - @Override - public boolean equals(Object other) { - if (this == other) - return true; - if (other == null || getClass() != other.getClass()) - return false; - BaseRequest o = (BaseRequest) other; - return data.equals(o.data) && canvas.equals(o.canvas); - } - - @Override - public String toString() { - return getClass().getSimpleName() + "[" + data + " - " + canvas.hashCode() + "]"; - } - +/******************************************************************************* + * Copyright (c) 2007, 2010 Association for Decentralized Information Management + * in Industry THTH ry. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * VTT Technical Research Centre of Finland - initial API and implementation + *******************************************************************************/ +package org.simantics.diagram.adapter; + +import org.simantics.db.request.Read; +import org.simantics.g2d.canvas.ICanvasContext; + +/** + * A base for synchronous requests performed by + * {@link GraphToDiagramSynchronizer}. + * + *

+ * Takes care of making this request unique for this + * {@link GraphToDiagramSynchronizer} instances by making the active + * {@link ICanvasContext} a part of the requests identity. + *

+ * + * @param type of stored data element + * @param query result type + */ +abstract class BaseRequest implements Read { + + final protected T data; + + final int hash; + + final ICanvasContext canvas; + + public BaseRequest(ICanvasContext canvas, T data) { + this.canvas = canvas; + assert canvas != null; + assert data != null; + this.data = data; + this.hash = data.hashCode() + 31 * canvas.hashCode(); + } + + @Override + public int hashCode() { + return hash; + } + + @Override + public boolean equals(Object other) { + if (this == other) + return true; + if (other == null || getClass() != other.getClass()) + return false; + BaseRequest o = (BaseRequest) other; + return data.equals(o.data) && canvas.equals(o.canvas); + } + + @Override + public String toString() { + return getClass().getSimpleName() + "[" + data + " - " + canvas.hashCode() + "]"; + } + } \ No newline at end of file