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.UnionType;
20 public interface UnionAccessor extends Accessor {
23 * Get the number of tag types
25 * @return the number of tag types
26 * @throws AccessorException
28 int count() throws AccessorException;
31 * Get the union tag index
34 * @throws AccessorException
36 int getTag() throws AccessorException;
39 * Get an accessor to the component value.
40 * The accessor becomes invalid if a new value is assigned.
42 * @return accessor to the value
43 * @throws AccessorConstructionException
45 <T extends Accessor> T getComponentAccessor() throws AccessorConstructionException;
50 * @param componentBinding component binding
52 * @throws AccessorException
54 Object getComponentValue(Binding componentBinding) throws AccessorException;
57 * Set a new Union value.
59 * If the tag-type changes and there is an accessor to the previous value,
64 * @throws BindingException binding error
65 * @throws UnsupportedOperationException cannot set a new value
67 void setValue(Binding unionBinding, Object newUnion) throws AccessorException;
70 * Set a new component value. The argument newValue may be captured or copied.
73 * @param componentBinding
74 * @param componentValue
75 * @throws AccessorException
77 void setComponentValue(int tag, Binding componentBinding, Object componentValue) throws AccessorException;