]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.databoard/src/org/simantics/databoard/adapter/AdapterRequest.java
Improved Bindings.getBinding(Class) caching for Datatype.class
[simantics/platform.git] / bundles / org.simantics.databoard / src / org / simantics / databoard / adapter / AdapterRequest.java
1 /*******************************************************************************
2  *  Copyright (c) 2010 Association for Decentralized Information Management in
3  *  Industry THTH ry.
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
8  *
9  *  Contributors:
10  *      VTT Technical Research Centre of Finland - initial API and implementation
11  *******************************************************************************/
12 package org.simantics.databoard.adapter;
13
14 import org.simantics.databoard.binding.Binding;
15
16 public class AdapterRequest {
17
18         Binding domain;
19         Binding range;
20         boolean mustClone;
21         
22         public AdapterRequest(Binding domain, Binding range)
23         {
24                 if (domain==null||range==null) throw new IllegalArgumentException("null arg");
25                 this.domain = domain;
26                 this.range = range;
27         }
28
29         public AdapterRequest(Binding domain, Binding range, boolean mustClone)
30         {
31                 if (domain==null||range==null) throw new IllegalArgumentException("null arg");
32                 this.domain = domain;
33                 this.range = range;
34                 this.mustClone = mustClone;
35         }
36         
37         public Binding getDomain() {
38                 return domain;
39         }
40         
41         public Binding getRange() {
42                 return range;
43         }
44
45         @Override
46         public int hashCode() {
47         return domain.hashCode() + 31*range.hashCode() + (mustClone ? 1 : 0);
48         }
49
50         @Override
51         public boolean equals(Object obj) {
52         if (obj == null) return false;
53         if (obj instanceof AdapterRequest == false) return false;
54         AdapterRequest other = (AdapterRequest) obj;
55         return other.domain.equals(domain) && other.range.equals(range) && mustClone==other.mustClone;
56         }
57         
58 }
59