1 /*******************************************************************************
\r
2 * Copyright (c) 2010 Association for Decentralized Information Management in
\r
4 * All rights reserved. This program and the accompanying materials
\r
5 * are made available under the terms of the Eclipse Public License v1.0
\r
6 * which accompanies this distribution, and is available at
\r
7 * http://www.eclipse.org/legal/epl-v10.html
\r
10 * VTT Technical Research Centre of Finland - initial API and implementation
\r
11 *******************************************************************************/
\r
12 package org.simantics.databoard.binding.reflection;
\r
14 import org.simantics.databoard.binding.Binding;
\r
15 import org.simantics.databoard.binding.RecordBinding;
\r
16 import org.simantics.databoard.binding.error.BindingException;
\r
17 import org.simantics.databoard.type.Datatype;
\r
19 public class ConstantBinding extends RecordBinding {
\r
23 public ConstantBinding(Datatype type, Object constantValue) {
\r
25 this.componentBindings = new Binding[0];
\r
26 this.value = constantValue;
\r
30 public Object create(Object... value) throws BindingException {
\r
35 public Object getComponent(Object obj, int index) throws BindingException {
\r
36 throw new BindingException();
\r
40 public Object createPartial() throws BindingException {
\r
45 public void setComponents(Object obj, Object... value) throws BindingException {
\r
46 // throw new BindingException();
\r
50 public void setComponent(Object obj, int index, Object value)
\r
51 throws BindingException {
\r
52 // throw new BindingException();
\r
56 public boolean isInstance(Object obj) {
\r
61 public boolean isImmutable() {
\r
66 protected boolean baseEquals( Object obj ) {
\r
67 return super.baseEquals( obj ) && value == ((ConstantBinding)obj).value;
\r
71 public int baseHashCode() {
\r
72 return super.baseHashCode() + 7 * value.hashCode();
\r