]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.databoard/src/org/simantics/databoard/accessor/interestset/OptionalInterestSet.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.databoard / src / org / simantics / databoard / accessor / interestset / OptionalInterestSet.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.OptionalType;
16
17 /**
18  * Interest set of an Optional Type.
19  * 
20  * @see OptionalType
21  * @author Toni Kalajainen <toni.kalajainen@vtt.fi>
22  */
23 public class OptionalInterestSet extends InterestSet {
24         
25         public static final OptionalInterestSet MONITOR_EVERYTHING = new OptionalInterestSet(true, true, null); 
26         
27         /** Interested in the notification of value assignment (excludes the value) */
28         public boolean notification = true;
29         /** Interested in the value (includes change) */  
30         public boolean value = true;
31         /** Component intersts, null if no specific interest */
32         public @Optional InterestSet componentInterest;
33                 
34         public OptionalInterestSet(boolean notification, boolean value, InterestSet componentInterest) {
35                 this.notification = notification;
36                 this.value = value;
37                 this.componentInterest = componentInterest;
38         }
39         
40         /**
41          * Returns true, if interested in the value or notification 
42          * 
43          * @return true, if interested in the value 
44          */
45         public boolean inValues() {
46                 return value | (componentInterest!=null);
47         }
48
49         /**
50          * Returns true, if interested in notification of new value assignments.
51          * 
52          * @return true, if interested in notification 
53          */
54         public boolean inNotifications() {
55                 return notification | value | (componentInterest!=null);
56         }       
57         
58         /**
59          * Returns component interest or <code>null</code>
60          * 
61          * @return interest of component or <code>null</code>
62          */
63         public InterestSet getComponentInterest() {
64                 return componentInterest;
65         }
66         
67 }
68