]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.diagram/src/org/simantics/diagram/symbolcontribution/SymbolGroup.java
Fixed multiple issues causing dangling references to discarded queries
[simantics/platform.git] / bundles / org.simantics.diagram / src / org / simantics / diagram / symbolcontribution / SymbolGroup.java
1 /*******************************************************************************
2  * Copyright (c) 2007, 2010 Association for Decentralized Information Management
3  * in Industry THTH ry.
4  * All rights reserved. This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License v1.0
6  * which accompanies this distribution, and is available at
7  * http://www.eclipse.org/legal/epl-v10.html
8  *
9  * Contributors:
10  *     VTT Technical Research Centre of Finland - initial API and implementation
11  *******************************************************************************/
12 package org.simantics.diagram.symbolcontribution;
13
14 import java.util.Arrays;
15
16 import org.simantics.diagram.symbollibrary.ISymbolGroup;
17 import org.simantics.diagram.symbollibrary.ISymbolItem;
18
19 /**
20  * @author Tuukka Lehtonen
21  */
22 public class SymbolGroup extends NamedObject implements ISymbolGroup {
23
24     public static final ISymbolItem[] NO_ITEMS = {};
25
26     ISymbolItem[] items = NO_ITEMS;
27
28     private final String description;
29
30     public SymbolGroup(Object identification, String name) {
31         this(identification, name, name);
32     }
33
34     public SymbolGroup(Object identification, String name, ISymbolItem[] items) {
35         this(identification, name, name, items);
36     }
37
38     public SymbolGroup(Object identification, String name, String description) {
39         super(identification, name);
40         this.description = description;
41     }
42
43     public SymbolGroup(Object identification, String name, String description, ISymbolItem[] items) {
44         super(identification, name);
45         this.description = description;
46         this.items = items;
47     }
48
49     @Override
50     public String getDescription() {
51         return description;
52     }
53
54     @Override
55     public ISymbolItem[] getItems() {
56         return items;
57     }
58
59     public void setItems(ISymbolItem[] items) {
60         this.items = items;
61     }
62
63     @Override
64     public String toString() {
65         return super.toString() + "[item count=" + items.length + "]";
66     }
67
68     @Override
69     public int hashCode() {
70         final int prime = 31;
71         int result = super.hashCode();
72         result = prime * result + ((description == null) ? 0 : description.hashCode());
73         result = prime * result + Arrays.hashCode(items);
74         return result;
75     }
76
77     @Override
78     public boolean equals(Object obj) {
79         if (this == obj)
80             return true;
81         if (!super.equals(obj))
82             return false;
83         if (getClass() != obj.getClass())
84             return false;
85         SymbolGroup other = (SymbolGroup) obj;
86         if (description == null) {
87             if (other.description != null)
88                 return false;
89         } else if (!description.equals(other.description))
90             return false;
91         if (!Arrays.equals(items, other.items))
92             return false;
93         return true;
94     }
95
96 }