1 /*******************************************************************************
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
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
10 * VTT Technical Research Centre of Finland - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.diagram.symbolcontribution;
14 import java.util.Collection;
15 import java.util.Collections;
16 import java.util.HashSet;
19 import org.simantics.diagram.symbollibrary.ISymbolGroup;
21 public abstract class AbstractSymbolProvider implements ISymbolProvider {
22 protected volatile boolean disposed = false;
23 protected Runnable listener;
24 protected Collection<ISymbolGroup> groups = Collections.emptyList();
25 private Set<ISymbolGroup> groupSet = null;
27 public Collection<ISymbolGroup> getSymbolGroups() {
31 public void setListener(Runnable listener) {
32 this.listener = listener;
35 public void dispose() {
39 void setSymbolGroup(Collection<ISymbolGroup> groups) {
41 throw new NullPointerException("null groups");
45 protected Set<ISymbolGroup> getSymbolGroupSet() {
49 groupSet = new HashSet<ISymbolGroup>(getSymbolGroups());
55 groups = Collections.unmodifiableCollection(groups);
61 public int hashCode() {
62 return getSymbolGroupSet().hashCode();
66 public boolean equals(Object obj) {
71 if (!(obj instanceof AbstractSymbolProvider))
73 AbstractSymbolProvider other = (AbstractSymbolProvider) obj;
74 return getSymbolGroupSet().equals( other.getSymbolGroupSet() );