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