]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.databoard/src/org/simantics/databoard/accessor/OptionalAccessor.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.databoard / src / org / simantics / databoard / accessor / OptionalAccessor.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;
13
14 import org.simantics.databoard.accessor.error.AccessorConstructionException;
15 import org.simantics.databoard.accessor.error.AccessorException;
16 import org.simantics.databoard.binding.Binding;
17 import org.simantics.databoard.binding.error.BindingException;
18 import org.simantics.databoard.type.OptionalType;
19
20
21 public interface OptionalAccessor extends Accessor {
22
23         /**
24          * Set a new value. Copies values from an Optional Value. 
25          * If existing sub-value is removed, then possibly existing accessor is 
26          * invalidated.
27          * 
28          * @param componentBinding of component type
29          * @param newComponentValue component value
30          * @throws BindingException binding error
31          * @throws UnsupportedOperationException cannot set a new value
32          */
33         void setValue(Binding componentBinding, Object newComponentValue) throws AccessorException;
34         
35         /**
36          * Sets no value. Any existing component accessor is invalidated.
37          * 
38          * @throws AccessorException
39          */
40         void setNoValue() throws AccessorException;
41         
42         /**
43          * Return true if there is a value assigned 
44          * 
45          * @return true if there is a value  
46          * @throws AccessorException
47          */
48         boolean hasValue() throws AccessorException;
49
50         /**
51          * Return component value if there is a component value.
52          * Exception is thrown if there is no component value.
53          * 
54          * @param componentBinding component binding
55          * @return component value 
56          * @throws AccessorException 
57          */
58         Object getComponentValue(Binding componentBinding) throws AccessorException;    
59         
60         /**
61          * Set a new component value. Any existing component accessor is invalidated.
62          * 
63          * @param componentBinding
64          * @param componentValue
65          * @throws AccessorException
66          */
67         void setComponentValue(Binding componentBinding, Object componentValue) throws AccessorException;
68         
69         /**
70          * Get accessor to the component value or <code>null</code> if there is no component value
71          * 
72          * @return accessor or <code>null</code>
73          * @throws AccessorConstructionException 
74          */
75         <T extends Accessor> T getComponentAccessor() throws AccessorConstructionException;
76         
77         OptionalType type();
78
79 }
80