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.type;
16 import org.simantics.databoard.accessor.error.ReferenceException;
17 import org.simantics.databoard.accessor.reference.ChildReference;
18 import org.simantics.databoard.util.IdentityPair;
21 public class BooleanType extends Datatype {
23 public BooleanType() {}
26 public int getComponentCount() {
31 public Datatype getComponentType(int index) {
32 throw new IllegalArgumentException();
36 public Datatype getComponentType(ChildReference path) {
37 if (path==null) return this;
38 throw new IllegalArgumentException();
42 public void accept(Visitor1 v, Object obj) {
47 public <T> T accept(Visitor<T> v) {
52 protected boolean deepEquals(Object obj,
53 Set<IdentityPair<Datatype, Datatype>> compareHistory) {
54 if (this==obj) return true;
55 if ( !hasEqualMetadata(obj) ) return false;
56 return obj instanceof BooleanType;
60 public int hashCode() {
61 return metadataHashCode() ^ 0xaaee333;
65 public boolean equals(Object obj) {
66 if ( this==obj ) return true;
67 if ( !hasEqualMetadata(obj) ) return false;
68 return obj instanceof BooleanType;
71 @SuppressWarnings("unchecked")
73 public <T extends Datatype> T getChildType(ChildReference reference) throws ReferenceException {
74 if (reference==null) return (T) this;
75 throw new ReferenceException(reference.getClass()+" is not a subreference of BooleanType");