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.reflection;
14 import org.simantics.databoard.binding.Binding;
15 import org.simantics.databoard.binding.RecordBinding;
16 import org.simantics.databoard.binding.error.BindingException;
17 import org.simantics.databoard.type.Datatype;
19 public class ConstantBinding extends RecordBinding {
23 public ConstantBinding(Datatype type, Object constantValue) {
25 this.componentBindings = new Binding[0];
26 this.value = constantValue;
30 public Object create(Object... value) throws BindingException {
35 public Object getComponent(Object obj, int index) throws BindingException {
36 throw new BindingException();
40 public Object createPartial() throws BindingException {
45 public void setComponents(Object obj, Object... value) throws BindingException {
46 // throw new BindingException();
50 public void setComponent(Object obj, int index, Object value)
51 throws BindingException {
52 // throw new BindingException();
56 public boolean isInstance(Object obj) {
61 public boolean isImmutable() {
66 protected boolean baseEquals( Object obj ) {
67 return super.baseEquals( obj ) && value == ((ConstantBinding)obj).value;
71 public int baseHashCode() {
72 return super.baseHashCode() + 7 * value.hashCode();