]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.diagram/src/org/simantics/diagram/symbolcontribution/SymbolGroup.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.diagram / src / org / simantics / diagram / symbolcontribution / SymbolGroup.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.diagram.symbolcontribution;\r
13 \r
14 import java.util.Arrays;\r
15 \r
16 import org.simantics.diagram.symbollibrary.ISymbolGroup;\r
17 import org.simantics.diagram.symbollibrary.ISymbolItem;\r
18 \r
19 /**\r
20  * @author Tuukka Lehtonen\r
21  */\r
22 public class SymbolGroup extends NamedObject implements ISymbolGroup {\r
23 \r
24     public static final ISymbolItem[] NO_ITEMS = {};\r
25 \r
26     ISymbolItem[] items = NO_ITEMS;\r
27 \r
28     private final String description;\r
29 \r
30     public SymbolGroup(Object identification, String name) {\r
31         this(identification, name, name);\r
32     }\r
33 \r
34     public SymbolGroup(Object identification, String name, ISymbolItem[] items) {\r
35         this(identification, name, name, items);\r
36     }\r
37 \r
38     public SymbolGroup(Object identification, String name, String description) {\r
39         super(identification, name);\r
40         this.description = description;\r
41     }\r
42 \r
43     public SymbolGroup(Object identification, String name, String description, ISymbolItem[] items) {\r
44         super(identification, name);\r
45         this.description = description;\r
46         this.items = items;\r
47     }\r
48 \r
49     @Override\r
50     public String getDescription() {\r
51         return description;\r
52     }\r
53 \r
54     @Override\r
55     public ISymbolItem[] getItems() {\r
56         return items;\r
57     }\r
58 \r
59     public void setItems(ISymbolItem[] items) {\r
60         this.items = items;\r
61     }\r
62 \r
63     @Override\r
64     public String toString() {\r
65         return super.toString() + "[item count=" + items.length + "]";\r
66     }\r
67 \r
68     @Override\r
69     public int hashCode() {\r
70         final int prime = 31;\r
71         int result = super.hashCode();\r
72         result = prime * result + ((description == null) ? 0 : description.hashCode());\r
73         result = prime * result + Arrays.hashCode(items);\r
74         return result;\r
75     }\r
76 \r
77     @Override\r
78     public boolean equals(Object obj) {\r
79         if (this == obj)\r
80             return true;\r
81         if (!super.equals(obj))\r
82             return false;\r
83         if (getClass() != obj.getClass())\r
84             return false;\r
85         SymbolGroup other = (SymbolGroup) obj;\r
86         if (description == null) {\r
87             if (other.description != null)\r
88                 return false;\r
89         } else if (!description.equals(other.description))\r
90             return false;\r
91         if (!Arrays.equals(items, other.items))\r
92             return false;\r
93         return true;\r
94     }\r
95 \r
96 }