-/*******************************************************************************\r
- * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
- * in Industry THTH ry.\r
- * All rights reserved. This program and the accompanying materials\r
- * are made available under the terms of the Eclipse Public License v1.0\r
- * which accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- * VTT Technical Research Centre of Finland - initial API and implementation\r
- *******************************************************************************/\r
-package org.simantics.diagram.symbolcontribution;\r
-\r
-import org.eclipse.core.runtime.IAdaptable;\r
-\r
-/**\r
- * @author Tuukka Lehtonen\r
- */\r
-public abstract class IdentifiedObject implements IAdaptable, IIdentifiedObject {\r
- Object identification;\r
-\r
- public IdentifiedObject(Object identification) {\r
- if (identification == null)\r
- throw new NullPointerException("null identification");\r
- this.identification = identification;\r
- }\r
-\r
- @Override\r
- public Object getId() {\r
- return identification;\r
- }\r
-\r
- @Override\r
- public int hashCode() {\r
- return identification.hashCode();\r
- }\r
-\r
- @Override\r
- public boolean equals(Object obj) {\r
- if (this == obj)\r
- return true;\r
- if (obj == null)\r
- return false;\r
- if (!(obj instanceof IdentifiedObject))\r
- return false;\r
- IdentifiedObject other = (IdentifiedObject) obj;\r
- return identification.equals(other.identification);\r
- }\r
-\r
- @SuppressWarnings("unchecked")\r
- protected <T> T adapt(Class<T> clazz) {\r
- if (clazz.isInstance(identification))\r
- return (T) identification;\r
- if (identification instanceof IAdaptable)\r
- return (T) ((IAdaptable) identification).getAdapter(clazz);\r
- return null;\r
- }\r
-\r
- @SuppressWarnings("rawtypes")\r
- @Override\r
- public Object getAdapter(Class adapter) {\r
- if (adapter.isInstance(identification))\r
- return identification;\r
- if (identification instanceof IAdaptable)\r
- return ((IAdaptable) identification).getAdapter(adapter);\r
- return null;\r
- }\r
-\r
- @Override\r
- public String toString() {\r
- return getClass().getSimpleName() + "[id=" + identification + "]";\r
- }\r
-\r
-}\r
+/*******************************************************************************
+ * 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.symbolcontribution;
+
+import org.eclipse.core.runtime.IAdaptable;
+
+/**
+ * @author Tuukka Lehtonen
+ */
+public abstract class IdentifiedObject implements IAdaptable, IIdentifiedObject {
+ Object identification;
+
+ public IdentifiedObject(Object identification) {
+ if (identification == null)
+ throw new NullPointerException("null identification");
+ this.identification = identification;
+ }
+
+ @Override
+ public Object getId() {
+ return identification;
+ }
+
+ @Override
+ public int hashCode() {
+ return identification.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (!(obj instanceof IdentifiedObject))
+ return false;
+ IdentifiedObject other = (IdentifiedObject) obj;
+ return identification.equals(other.identification);
+ }
+
+ @SuppressWarnings("unchecked")
+ protected <T> T adapt(Class<T> clazz) {
+ if (clazz.isInstance(identification))
+ return (T) identification;
+ if (identification instanceof IAdaptable)
+ return (T) ((IAdaptable) identification).getAdapter(clazz);
+ return null;
+ }
+
+ @SuppressWarnings("rawtypes")
+ @Override
+ public Object getAdapter(Class adapter) {
+ if (adapter.isInstance(identification))
+ return identification;
+ if (identification instanceof IAdaptable)
+ return ((IAdaptable) identification).getAdapter(adapter);
+ return null;
+ }
+
+ @Override
+ public String toString() {
+ return getClass().getSimpleName() + "[id=" + identification + "]";
+ }
+
+}