]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.browsing.ui.common/src/org/simantics/browsing/ui/common/labelers/LabelerContent.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.browsing.ui.common / src / org / simantics / browsing / ui / common / labelers / LabelerContent.java
1 /*******************************************************************************\r
2  * Copyright (c) 2007, 2010 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
8  *\r
9  * Contributors:\r
10  *     VTT Technical Research Centre of Finland - initial API and implementation\r
11  *******************************************************************************/\r
12 package org.simantics.browsing.ui.common.labelers;\r
13 \r
14 import java.util.Arrays;\r
15 import java.util.Map;\r
16 \r
17 import org.simantics.browsing.ui.content.Labeler;\r
18 \r
19 public class LabelerContent {\r
20 \r
21         public static LabelerContent NO_CONTENT = new LabelerContent(0, Labeler.NO_LABELS);\r
22 \r
23         public final int                 category;\r
24     public final Map<String, String> labels;\r
25     \r
26     public LabelerContent(int category, Map<String, String> labels) {\r
27         this.category = category;\r
28         this.labels = labels;\r
29     }\r
30     \r
31     @Override\r
32     public String toString() {\r
33         return "LabelerContent[" + Arrays.toString(labels.values().toArray()) + "]";\r
34     }\r
35     \r
36     @Override\r
37     public int hashCode() {\r
38         return category + 31 * labels.hashCode();\r
39     }\r
40     \r
41     @Override\r
42     public boolean equals(Object object) {\r
43         \r
44         if (this == object)\r
45             return true;\r
46         else if (object == null)\r
47             return false;\r
48         else if (!(object instanceof LabelerContent))\r
49             return false;\r
50 \r
51         LabelerContent lc = (LabelerContent)object;\r
52         return category == lc.category && labels.equals(lc.labels);\r
53         \r
54     }\r
55     \r
56 }\r