1 /*******************************************************************************
2 * Copyright (c) 2010 Association for Decentralized Information Management in
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.databoard.accessor.interestset;
14 import org.simantics.databoard.annotations.Optional;
15 import org.simantics.databoard.type.VariantType;
18 * Interest set of Variant Type.
21 * @author Toni Kalajainen <toni.kalajainen@vtt.fi>
23 public class VariantInterestSet extends InterestSet {
25 public static final VariantInterestSet MONITOR_EVERYTHING = new VariantInterestSet(true, true, null, true);
28 /** Interested in notification (excludes the value) */
29 public boolean notification;
32 /** Interested in the value assignment (includes notification) */
36 /** Component intersts, null if no specific interest */
37 public @Optional InterestSet componentInterest;
39 /** Interested in the complete structure of the container. Includes interest in value assignment and notification */
40 public boolean completeComponent;
43 * Create a new interest set of a variant.
45 * @param notification interest in notification of assignment
46 * @param value interest in notification and the new value of value assignment
47 * @param componentInterest specific interest in the value
48 * @param completeContainer interest in notification, the new value and complete sub structure of the container
50 public VariantInterestSet(boolean notification, boolean value, InterestSet componentInterest, boolean completeContainer) {
51 this.notification = notification;
53 this.completeComponent = completeContainer;
54 this.componentInterest = componentInterest;
58 * Returns true, if interested in notification of value assignment.
59 * This doesn't include interest in the new value.
61 * @return true, if interested in notification of value assignment.
63 public boolean inNotifications() {
64 return notification | value | completeComponent | (componentInterest!=null);
68 * Returns true, if interested in the value assignment
70 * @return true, if interested in the value assignment
72 public boolean inValues() {
73 return value | completeComponent | (componentInterest!=null);
77 * Returns true, if interested in everything in the sub container, value assignment and change
79 * @return true, if has interest to the complete sub-tree of the component
81 public boolean inCompleteComponent() {
82 return completeComponent;
86 * Component interest of expected type. If interest set doesn't match the type of
87 * the assigned value, then this field is ignored.
89 * @return the interest of the component, or <code>null</code>
91 public InterestSet getComponentInterest() {
92 return componentInterest;