X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.diagram%2Fsrc%2Forg%2Fsimantics%2Fdiagram%2Fsymbolcontribution%2FIdentifiedObject.java;h=138c0cb996d3d478a5578ee0d1af6f5d0adbe515;hb=fe216008faa34a8db02d0c53fc97e71cb70f64c0;hp=f098f4827cc87f9a767633cffa7d2e1e0af38345;hpb=969bd23cab98a79ca9101af33334000879fb60c5;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.diagram/src/org/simantics/diagram/symbolcontribution/IdentifiedObject.java b/bundles/org.simantics.diagram/src/org/simantics/diagram/symbolcontribution/IdentifiedObject.java index f098f4827..138c0cb99 100644 --- a/bundles/org.simantics.diagram/src/org/simantics/diagram/symbolcontribution/IdentifiedObject.java +++ b/bundles/org.simantics.diagram/src/org/simantics/diagram/symbolcontribution/IdentifiedObject.java @@ -1,74 +1,74 @@ -/******************************************************************************* - * 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 adapt(Class 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 + "]"; - } - -} +/******************************************************************************* + * 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 adapt(Class 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 + "]"; + } + +}