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