1 /*******************************************************************************
2 * Copyright (c) 2007, 2013 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.participant;
14 import java.util.Collection;
15 import java.util.Collections;
18 * @author Tuukka Lehtonen
20 public class ContextState {
22 private Collection<String> contexts;
23 private boolean contextsSet;
25 public ContextState() {
26 this.contexts = Collections.emptyList();
27 this.contextsSet = false;
30 public ContextState(String context) {
31 this.contexts = Collections.singleton(context);
32 this.contextsSet = true;
35 public ContextState(Collection<String> contexts) {
36 setContexts(contexts);
39 void setContexts(Collection<String> contexts) {
41 throw new IllegalStateException("contexts can only be set once");
42 this.contexts = Collections.unmodifiableCollection(contexts);
43 this.contextsSet = true;
46 Collection<String> getContexts() {
50 boolean contextsAreSet() {
55 public String toString() {
56 return "ContextState : " + getContexts().toString();