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%2Fcontentassist%2FNamedObject.java;fp=bundles%2Forg.simantics.browsing.ui.swt%2Fsrc%2Forg%2Fsimantics%2Fbrowsing%2Fui%2Fswt%2Fcontentassist%2FNamedObject.java;h=8e122b7b8687a5ef8bfe268ad43b98b5c52aa3be;hp=0000000000000000000000000000000000000000;hb=969bd23cab98a79ca9101af33334000879fb60c5;hpb=866dba5cd5a3929bbeae85991796acb212338a08 diff --git a/bundles/org.simantics.browsing.ui.swt/src/org/simantics/browsing/ui/swt/contentassist/NamedObject.java b/bundles/org.simantics.browsing.ui.swt/src/org/simantics/browsing/ui/swt/contentassist/NamedObject.java new file mode 100644 index 000000000..8e122b7b8 --- /dev/null +++ b/bundles/org.simantics.browsing.ui.swt/src/org/simantics/browsing/ui/swt/contentassist/NamedObject.java @@ -0,0 +1,86 @@ +/******************************************************************************* + * Copyright (c) 2010, 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.contentassist; + +/** + * @author Tuukka Lehtonen + */ +public class NamedObject implements INamedObject { + + private final T object; + private final String name; + private final String label; + private final String description; + + public NamedObject(T object, String name) { + this(object, name, name); + } + + public NamedObject(T object, String name, String label) { + this(object, name, label, null); + } + + public NamedObject(T object, String name, String label, String description) { + this.object = object; + this.name = name; + this.label = label; + this.description = description; + } + + @Override + public String getName() { + return name; + } + + public String getLabel() { + return label; + } + + public String getDescription() { + return description; + } + + public T getObject() { + return object; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((object == null) ? 0 : object.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + NamedObject other = (NamedObject) obj; + if (object == null) { + if (other.object != null) + return false; + } else if (!object.equals(other.object)) + return false; + return true; + } + + @Override + public String toString() { + return getClass().getSimpleName() + "[name=" + name + "]"; + } + +}