1 /*******************************************************************************
\r
2 * Copyright (c) 2010, 2012 Association for Decentralized Information Management
\r
3 * in Industry THTH ry.
\r
4 * All rights reserved. This program and the accompanying materials
\r
5 * are made available under the terms of the Eclipse Public License v1.0
\r
6 * which accompanies this distribution, and is available at
\r
7 * http://www.eclipse.org/legal/epl-v10.html
\r
10 * VTT Technical Research Centre of Finland - initial API and implementation
\r
11 *******************************************************************************/
\r
12 package org.simantics.browsing.ui.swt.contentassist;
\r
15 * @author Tuukka Lehtonen
\r
17 public class NamedObject<T> implements INamedObject {
\r
19 private final T object;
\r
20 private final String name;
\r
21 private final String label;
\r
22 private final String description;
\r
24 public NamedObject(T object, String name) {
\r
25 this(object, name, name);
\r
28 public NamedObject(T object, String name, String label) {
\r
29 this(object, name, label, null);
\r
32 public NamedObject(T object, String name, String label, String description) {
\r
33 this.object = object;
\r
36 this.description = description;
\r
40 public String getName() {
\r
44 public String getLabel() {
\r
48 public String getDescription() {
\r
52 public T getObject() {
\r
57 public int hashCode() {
\r
58 final int prime = 31;
\r
60 result = prime * result + ((object == null) ? 0 : object.hashCode());
\r
65 public boolean equals(Object obj) {
\r
70 if (getClass() != obj.getClass())
\r
72 NamedObject<?> other = (NamedObject<?>) obj;
\r
73 if (object == null) {
\r
74 if (other.object != null)
\r
76 } else if (!object.equals(other.object))
\r
82 public String toString() {
\r
83 return getClass().getSimpleName() + "[name=" + name + "]";
\r