1 /*******************************************************************************
\r
2 * Copyright (c) 2010 Association for Decentralized Information Management in
\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.databoard.accessor.interestset;
14 import org.simantics.databoard.annotations.Optional;
\r
15 import org.simantics.databoard.type.UnionType;
\r
18 * Interest set of Union Type.
21 * @author Toni Kalajainen <toni.kalajainen@vtt.fi>
23 public class UnionInterestSet extends InterestSet {
25 public static final UnionInterestSet MONITOR_EVERYTHING = new UnionInterestSet(true, true, null);
27 /** Interested in the notifications (excludes the value) */
28 public boolean notification = true;
29 /** Interested in the value (includes notification) */
30 public boolean value = true;
31 /** Component intersts, null if no specific interest */
32 public @Optional InterestSet[] componentInterests;
34 public UnionInterestSet(boolean notification, boolean value, InterestSet[] componentInterests) {
35 this.notification = notification;
37 this.componentInterests = componentInterests;
41 * Returns true, if interested in notification.
43 * @return true, if interested in notification
45 public boolean inNotifications() {
46 return notification | value;
49 public boolean inNotificationsOf(int tag) {
50 return notification | value | getComponentInterest(tag)!=null;
54 * Returns true, if interested in the value
56 * @return true, if interested in the value
58 public boolean inValues() {
62 public boolean inValuesOf(int tag) {
63 return value | getComponentInterest(tag)!=null;
67 * Get interest in the component value.
69 * @return component interest or <code>null</code>
71 public InterestSet getComponentInterest(int tag) {
72 if (componentInterests==null) return null;
73 return componentInterests[tag];