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;
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;
21 public interface OptionalAccessor extends Accessor {
24 * Set a new value. Copies values from an Optional Value.
25 * If existing sub-value is removed, then possibly existing accessor is
28 * @param componentBinding of component type
29 * @param newComponentValue component value
30 * @throws BindingException binding error
31 * @throws UnsupportedOperationException cannot set a new value
33 void setValue(Binding componentBinding, Object newComponentValue) throws AccessorException;
36 * Sets no value. Any existing component accessor is invalidated.
38 * @throws AccessorException
40 void setNoValue() throws AccessorException;
43 * Return true if there is a value assigned
45 * @return true if there is a value
46 * @throws AccessorException
48 boolean hasValue() throws AccessorException;
51 * Return component value if there is a component value.
52 * Exception is thrown if there is no component value.
54 * @param componentBinding component binding
55 * @return component value
56 * @throws AccessorException
58 Object getComponentValue(Binding componentBinding) throws AccessorException;
61 * Set a new component value. Any existing component accessor is invalidated.
63 * @param componentBinding
64 * @param componentValue
65 * @throws AccessorException
67 void setComponentValue(Binding componentBinding, Object componentValue) throws AccessorException;
70 * Get accessor to the component value or <code>null</code> if there is no component value
72 * @return accessor or <code>null</code>
73 * @throws AccessorConstructionException
75 <T extends Accessor> T getComponentAccessor() throws AccessorConstructionException;