]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.databoard/src/org/simantics/databoard/accessor/interestset/VariantInterestSet.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.databoard / src / org / simantics / databoard / accessor / interestset / VariantInterestSet.java
1 /*******************************************************************************
2  *  Copyright (c) 2010 Association for Decentralized Information Management in
3  *  Industry THTH ry.
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
8  *
9  *  Contributors:
10  *      VTT Technical Research Centre of Finland - initial API and implementation
11  *******************************************************************************/
12 package org.simantics.databoard.accessor.interestset;
13
14 import org.simantics.databoard.annotations.Optional;
15 import org.simantics.databoard.type.VariantType;
16
17 /**
18  * Interest set of Variant Type.
19  *
20  * @see VariantType
21  * @author Toni Kalajainen <toni.kalajainen@vtt.fi>
22  */
23 public class VariantInterestSet extends InterestSet {
24         
25         public static final VariantInterestSet MONITOR_EVERYTHING = new VariantInterestSet(true, true, null, true); 
26         
27         // Notification
28         /** Interested in notification (excludes the value) */
29         public boolean notification;
30         
31         // Value Assignment
32         /** Interested in the value assignment (includes notification) */  
33         public boolean value;
34         
35         // Component
36         /** Component intersts, null if no specific interest */
37         public @Optional InterestSet componentInterest;
38         
39         /** Interested in the complete structure of the container. Includes interest in value assignment and notification */
40         public boolean completeComponent;
41                 
42         /**
43          * Create a new interest set of a variant.
44          * 
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
49          */
50         public VariantInterestSet(boolean notification, boolean value, InterestSet componentInterest, boolean completeContainer) {
51                 this.notification = notification;
52                 this.value = value;
53                 this.completeComponent = completeContainer;
54                 this.componentInterest = componentInterest;
55         }
56
57         /**
58          * Returns true, if interested in notification of value assignment.
59          * This doesn't include interest in the new value.
60          * 
61          * @return true, if interested in notification of value assignment.
62          */
63         public boolean inNotifications() {
64                 return notification | value | completeComponent | (componentInterest!=null);
65         }       
66         
67         /**
68          * Returns true, if interested in the value assignment  
69          * 
70          * @return true, if interested in the value assignment
71          */
72         public boolean inValues() {
73                 return value | completeComponent | (componentInterest!=null);
74         }
75         
76         /**
77          * Returns true, if interested in everything in the sub container, value assignment and change 
78          * 
79          * @return true, if has interest to the complete sub-tree of the component
80          */
81         public boolean inCompleteComponent() {
82                 return completeComponent;
83         }
84         
85         /**
86          * Component interest of expected type. If interest set doesn't match the type of
87          * the assigned value, then this field is ignored.
88          * 
89          * @return the interest of the component, or <code>null</code>
90          */
91         public InterestSet getComponentInterest() {
92                 return componentInterest;
93         }
94         
95 }
96