1 package org.simantics.db.layer0.variable;
3 import org.simantics.databoard.type.Datatype;
4 import org.simantics.utils.ObjectUtils;
7 * @author Tuukka Lehtonen
9 public class VariableReference {
11 public final RVI variableId;
13 public final Datatype datatype;
17 public static VariableReference of(RVI variableId, Datatype datatype, String label) {
18 return new VariableReference(variableId, datatype, label);
21 public VariableReference(RVI variableId, Datatype datatype, String label) {
22 if (variableId == null)
23 throw new NullPointerException("null variable reference");
24 this.variableId = variableId;
25 this.datatype = datatype;
29 public RVI getVariableId() {
33 public Datatype getDatatype() {
37 public String getLabel() {
42 public int hashCode() {
43 return ObjectUtils.hashCode(datatype) * 31 + variableId.hashCode();
47 public boolean equals(Object obj) {
52 if (getClass() != obj.getClass())
54 VariableReference other = (VariableReference) obj;
55 return variableId.equals(other.variableId) && ObjectUtils.objectEquals(datatype, other.datatype);
56 // && ObjectUtils.objectEquals(label, other.label);
60 public String toString() {
61 StringBuilder sb = new StringBuilder();
62 sb.append(variableId);
64 sb.append(" : ").append(datatype.toSingleLineString());
66 sb.append(" (").append(label).append(")");