X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.browsing.ui.swt%2Fsrc%2Forg%2Fsimantics%2Fbrowsing%2Fui%2Fswt%2Finputs%2FDatum.java;h=1191358168be235cd366ed9a731bf04d7b8f4a44;hp=6a554f4ac0f328f6f0d707236449fd0011eb377d;hb=0ae2b770234dfc3cbb18bd38f324125cf0faca07;hpb=24e2b34260f219f0d1644ca7a138894980e25b14 diff --git a/bundles/org.simantics.browsing.ui.swt/src/org/simantics/browsing/ui/swt/inputs/Datum.java b/bundles/org.simantics.browsing.ui.swt/src/org/simantics/browsing/ui/swt/inputs/Datum.java index 6a554f4ac..119135816 100644 --- a/bundles/org.simantics.browsing.ui.swt/src/org/simantics/browsing/ui/swt/inputs/Datum.java +++ b/bundles/org.simantics.browsing.ui.swt/src/org/simantics/browsing/ui/swt/inputs/Datum.java @@ -1,68 +1,68 @@ -/******************************************************************************* - * Copyright (c) 2007, 2012 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.browsing.ui.swt.inputs; - -import org.eclipse.core.runtime.IAdaptable; - -/** - * An equals-comparable and adaptable container for a single datum. The datum - * may be null. Adaptability is provided through {@link IAdaptable} - * . - * - * @author Tuukka Lehtonen - * - * @param the type of the datum - */ -public class Datum implements IAdaptable { - - protected final T datum; - - public Datum(T datum) { - this.datum = datum; - } - - public T getDatum() { - return datum; - } - - @SuppressWarnings({ "unchecked", "rawtypes" }) - @Override - public Object getAdapter(Class adapter) { - if (datum != null) { - if (adapter.isAssignableFrom(datum.getClass())) - return datum; - if (datum instanceof IAdaptable) - return ((IAdaptable) datum).getAdapter(adapter); - } - return null; - } - - @Override - public int hashCode() { - return datum != null ? datum.hashCode() : 0; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - Datum other = (Datum) obj; - if (datum == null) - return datum == other.datum; - return datum.equals(other.datum); - } - +/******************************************************************************* + * Copyright (c) 2007, 2012 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.browsing.ui.swt.inputs; + +import org.eclipse.core.runtime.IAdaptable; + +/** + * An equals-comparable and adaptable container for a single datum. The datum + * may be null. Adaptability is provided through {@link IAdaptable} + * . + * + * @author Tuukka Lehtonen + * + * @param the type of the datum + */ +public class Datum implements IAdaptable { + + protected final T datum; + + public Datum(T datum) { + this.datum = datum; + } + + public T getDatum() { + return datum; + } + + @SuppressWarnings({ "unchecked", "rawtypes" }) + @Override + public Object getAdapter(Class adapter) { + if (datum != null) { + if (adapter.isAssignableFrom(datum.getClass())) + return datum; + if (datum instanceof IAdaptable) + return ((IAdaptable) datum).getAdapter(adapter); + } + return null; + } + + @Override + public int hashCode() { + return datum != null ? datum.hashCode() : 0; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + Datum other = (Datum) obj; + if (datum == null) + return datum == other.datum; + return datum.equals(other.datum); + } + } \ No newline at end of file