1 /*******************************************************************************
\r
2 * Copyright (c) 2007, 2015 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 * Semantum Oy - added getHintsUnsafe
\r
12 *******************************************************************************/
\r
15 * @author Toni Kalajainen
\r
17 package org.simantics.utils.datastructures.hints;
\r
19 import java.util.Map;
\r
21 import org.simantics.utils.datastructures.hints.IHintContext.Key;
\r
22 import org.simantics.utils.threads.IThreadWorkQueue;
\r
25 public interface IHintObservable {
\r
28 * Check if this observable contains a value for the specified hint key.
\r
30 * @param key the key to check for a value
\r
31 * @return <code>true</code> if there is a value, <code>false</code> otherwise
\r
33 boolean containsHint(Key key);
\r
37 * @param <E> type of the object bound to the specified key
\r
39 * @return the hint or <code>null</code> if does not exist
\r
41 <E> E getHint(Key key);
\r
44 * Get all hints in this context
\r
45 * @return a snapshot of all the hints in this context
\r
47 Map<Key, Object> getHints();
\r
50 * Get all hints in this context without creating defensive copies in the
\r
51 * implementation if possible.
\r
53 * Use this only when reading and you know what you're doing.
\r
55 * @return the backing map of hints in this context without extra copying if possible
\r
57 Map<Key, Object> getHintsUnsafe();
\r
60 * Get all hints whose key is a subclass of <code>clazz</code>
\r
62 * @param clazz the class
\r
63 * @return key object map
\r
65 <E extends Key> Map<E, Object> getHintsOfClass(Class<E> clazz);
\r
68 * Adds hint listener, which gets events for all hint changes
\r
72 void addHintListener(IHintListener listener);
\r
75 * Removes hint listener
\r
79 void removeHintListener(IHintListener listener);
\r
82 * Adds hint listener for a specific key
\r
86 void addKeyHintListener(Key key, IHintListener listener);
\r
89 * Removes hint listener
\r
93 void removeKeyHintListener(Key key, IHintListener listener);
\r
96 * Adds hint listener, which gets events for all hint changes
\r
98 * @param threadAccess
\r
101 void addHintListener(IThreadWorkQueue threadAccess, IHintListener listener);
\r
104 * Removes hint listener
\r
106 * @param threadAccess
\r
109 void removeHintListener(IThreadWorkQueue threadAccess, IHintListener listener);
\r
112 * Adds hint listener for a specific key
\r
113 * @param threadAccess
\r
117 void addKeyHintListener(IThreadWorkQueue threadAccess, Key key, IHintListener listener);
\r
120 * Removes hint listener
\r
121 * @param threadAccess
\r
125 void removeKeyHintListener(IThreadWorkQueue threadAccess, Key key, IHintListener listener);
\r