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.binding.mutable;
14 import org.simantics.databoard.binding.FloatBinding;
15 import org.simantics.databoard.binding.error.BindingException;
16 import org.simantics.databoard.primitives.MutableFloat;
17 import org.simantics.databoard.type.FloatType;
20 * Binds FloatType to {@link MutableFloat}
22 * @author Toni Kalajainen <toni.kalajainen@vtt.fi>
24 public class MutableFloatBinding extends FloatBinding {
26 public MutableFloatBinding(FloatType type) {
31 public Object create(float value) {
32 MutableFloat result = new MutableFloat();
38 public Object create(Float value) {
39 MutableFloat result = new MutableFloat();
45 public Object create(Number value) {
46 MutableFloat result = new MutableFloat();
47 result.value = value.floatValue();
52 public Object create(String value) {
53 MutableFloat result = new MutableFloat();
54 result.value = Float.valueOf(value);
59 public float getValue_(Object o) throws BindingException {
60 MutableFloat result = (MutableFloat) o;
65 public Float getValue(Object o) throws BindingException {
66 MutableFloat result = (MutableFloat) o;
71 public boolean isInstance(Object obj) {
72 return obj instanceof MutableFloat;
76 public void setValue(Object obj, float value) throws BindingException {
77 MutableFloat result = (MutableFloat) obj;
82 public void setValue(Object obj, Number value) throws BindingException {
83 MutableFloat result = (MutableFloat) obj;
84 result.value = value.floatValue();